diff --git a/examples/device-dashboard/web.c b/examples/device-dashboard/web.c index 613ea15f..4fcd060d 100644 --- a/examples/device-dashboard/web.c +++ b/examples/device-dashboard/web.c @@ -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")) { diff --git a/mongoose.c b/mongoose.c index 76dac558..a36ccb8e 100644 --- a/mongoose.c +++ b/mongoose.c @@ -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; } diff --git a/src/sock.c b/src/sock.c index 9144df87..b71a1d10 100644 --- a/src/sock.c +++ b/src/sock.c @@ -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; }