mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-14 10:20:01 +00:00
RTX nits
This commit is contained in:
1 parent
cac7007069
commit
47e15a3d47
3 files changed
+11
-2
No files matched your search
@@ -31,7 +31,8 @@ static bool update_config(struct mg_http_message *hm, struct config *cfg) {
|
||||
}
|
||||
if (mg_http_get_var(&hm->body, "value2", buf, sizeof(buf)) > 0) {
|
||||
free(cfg->value2);
|
||||
cfg->value2 = strdup(buf);
|
||||
cfg->value2 = malloc(strlen(buf) + 1);
|
||||
strcpy(cfg->value2, buf);
|
||||
changed = true;
|
||||
}
|
||||
return changed;
|
||||
@@ -82,7 +83,9 @@ void device_dashboard_fn(struct mg_connection *c, int ev, void *ev_data,
|
||||
struct user *u = getuser(hm);
|
||||
// MG_INFO(("%p [%.*s] auth %s", c->fd, (int) hm->uri.len, hm->uri.ptr,
|
||||
// u ? u->name : "NULL"));
|
||||
if (u == NULL && mg_http_match_uri(hm, "/api/#")) {
|
||||
if (mg_http_match_uri(hm, "/api/hi")) {
|
||||
mg_http_reply(c, 200, "", "hi\n"); // Testing endpoint
|
||||
} else if (u == NULL && mg_http_match_uri(hm, "/api/#")) {
|
||||
// All URIs starting with /api/ must be authenticated
|
||||
mg_printf(c, "%s", "HTTP/1.1 403 Denied\r\nContent-Length: 0\r\n\r\n");
|
||||
} else if (mg_http_match_uri(hm, "/api/config/get")) {
|
||||
|
||||
@@ -3288,6 +3288,9 @@ static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
|
||||
if (n > 0) setlocaddr(FD(c), &c->loc);
|
||||
} else {
|
||||
n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
|
||||
#if MG_ARCH == MG_ARCH_RTX
|
||||
if (n == BSD_EWOULDBLOCK) return 0;
|
||||
#endif
|
||||
}
|
||||
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
|
||||
}
|
||||
|
||||
@@ -152,6 +152,9 @@ static long mg_sock_send(struct mg_connection *c, const void *buf, size_t len) {
|
||||
if (n > 0) setlocaddr(FD(c), &c->loc);
|
||||
} else {
|
||||
n = send(FD(c), (char *) buf, len, MSG_NONBLOCKING);
|
||||
#if MG_ARCH == MG_ARCH_RTX
|
||||
if (n == BSD_EWOULDBLOCK) return 0;
|
||||
#endif
|
||||
}
|
||||
return n == 0 ? -1 : n < 0 && mg_sock_would_block() ? 0 : n;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user