Skip to content

Commit

Permalink
is_closing -> is_draining
Browse files Browse the repository at this point in the history
  • Loading branch information
scaprile committed Aug 17, 2023
1 parent 36fcb7e commit 2b20af3
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/esp8266/http-client-server/src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void cb2(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
} else if (ev == MG_EV_HTTP_MSG) {
struct mg_http_message *hm = ev_data; // Print HTTP response
MG_INFO(("Fetched:\n%.*s", (int) hm->message.len, hm->message.ptr));
c->is_closing = 1;
c->is_draining = 1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/http-client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
// Response is received. Print it
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
printf("%.*s", (int) hm->message.len, hm->message.ptr);
c->is_closing = 1; // Tell mongoose to close this connection
c->is_draining = 1; // Tell mongoose to close this connection
*(bool *) fn_data = true; // Tell event loop to stop
} else if (ev == MG_EV_ERROR) {
*(bool *) fn_data = true; // Error, tell event loop to stop
Expand Down
2 changes: 1 addition & 1 deletion examples/http-streaming-client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
// Response is received. Print it
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
fwrite(hm->body.ptr, 1, hm->body.len, stdout);
c->is_closing = 1; // Tell mongoose to close this connection
c->is_draining = 1; // Tell mongoose to close this connection
*(bool *) fn_data = true; // Tell event loop to stop
} else if (ev == MG_EV_ERROR) {
*(bool *) fn_data = true; // Error, tell event loop to stop
Expand Down
2 changes: 1 addition & 1 deletion examples/mip-pcap/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void fn2(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
MG_DEBUG(("Got response (%d) %.*s...", (int) hm->message.len, 12,
hm->message.ptr));
c->is_closing = 1;
c->is_draining = 1;
} else if (ev == MG_EV_CONNECT) {
mg_printf(c, "GET %s HTTP/1.1\r\n\r\n", mg_url_uri((char *) fn_data));
} else if (ev == MG_EV_CLOSE) {
Expand Down
4 changes: 2 additions & 2 deletions examples/mqtt-over-ws-client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
len = mg_ws_wrap(c, c->send.len - len, WEBSOCKET_OP_BINARY);
} else {
MG_ERROR(("%lu MQTT auth failed, code %d", c->id, mm.ack));
c->is_closing = 1;
c->is_draining = 1;
}
break;
case MQTT_CMD_PUBLISH: {
MG_DEBUG(("%lu [%.*s] -> [%.*s]", c->id, (int) mm.topic.len,
mm.topic.ptr, (int) mm.data.len, mm.data.ptr));
MG_INFO(("RECEIVED %.*s <- %.*s", (int) mm.data.len, mm.data.ptr,
(int) mm.topic.len, mm.topic.ptr));
c->is_closing = 1;
c->is_draining = 1;
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/socks5-server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum {
static void handshake(struct mg_connection *c) {
struct mg_iobuf *r = &c->recv;
if (r->buf[0] != VERSION) {
c->is_closing = 1;
c->is_draining = 1;
} else if (r->len > 2 && (size_t) r->buf[1] + 2 <= r->len) {
/* https://www.ietf.org/rfc/rfc1928.txt paragraph 3 */
uint8_t reply[2] = {VERSION, HANDSHAKE_FAILURE};
Expand Down
6 changes: 3 additions & 3 deletions examples/uart-bridge/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ static void config_apply(struct mg_str s) {
if (mg_json_get_num(s, "$.tx", &v)) s_state.tx = (int) v;
if (mg_json_get_num(s, "$.baud", &v)) s_state.baud = (int) v;

if (s_state.mqtt.c) s_state.mqtt.c->is_closing = 1;
if (s_state.tcp.c) s_state.tcp.c->is_closing = 1;
if (s_state.websocket.c) s_state.websocket.c->is_closing = 1;
if (s_state.mqtt.c) s_state.mqtt.c->is_draining = 1;
if (s_state.tcp.c) s_state.tcp.c->is_draining = 1;
if (s_state.websocket.c) s_state.websocket.c->is_draining = 1;
}

// HTTP request handler function
Expand Down
2 changes: 1 addition & 1 deletion examples/zephyr/http-client/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
// Response is received. Print it
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
MG_INFO(("%.*s", (int) hm->message.len, hm->message.ptr));
c->is_closing = 1; // Tell mongoose to close this connection
c->is_draining = 1; // Tell mongoose to close this connection
*(bool *) fn_data = true; // Tell event loop to stop
} else if (ev == MG_EV_ERROR) {
*(bool *) fn_data = true; // Error, tell event loop to stop
Expand Down

0 comments on commit 2b20af3

Please sign in to comment.