Rename struct mg_connection::label -> data. Make its size configurable

This commit is contained in:
cpq committed 2023-01-10 08:19:49 +00:00
1 parent 3d75d71767
commit da5e8e9778
27 files changed
+3204 -2247

No files matched your search

+5 -5
View File
@@ -355,7 +355,7 @@ static void static_cb(struct mg_connection *c, int ev, void *ev_data,
struct mg_fd *fd = (struct mg_fd *) fn_data;
// Read to send IO buffer directly, avoid extra on-stack buffer
size_t n, max = MG_IO_SIZE, space;
size_t *cl = (size_t *) &c->label[(sizeof(c->label) - sizeof(size_t)) /
size_t *cl = (size_t *) &c->data[(sizeof(c->data) - sizeof(size_t)) /
sizeof(size_t) * sizeof(size_t)];
if (c->send.size < max) mg_iobuf_resize(&c->send, max);
if (c->send.len >= c->send.size) return; // Rate limit
@@ -527,8 +527,8 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
c->is_resp = 0;
mg_fs_close(fd);
} else {
// Track to-be-sent content length at the end of c->label, aligned
size_t *clp = (size_t *) &c->label[(sizeof(c->label) - sizeof(size_t)) /
// Track to-be-sent content length at the end of c->data, aligned
size_t *clp = (size_t *) &c->data[(sizeof(c->data) - sizeof(size_t)) /
sizeof(size_t) * sizeof(size_t)];
c->pfn = static_cb;
c->pfn_data = fd;
@@ -982,7 +982,7 @@ static void mg_hfn(struct mg_connection *c, int ev, void *ev_data, void *fnd) {
if (mg_http_match_uri(hm, "/quit")) {
mg_http_reply(c, 200, "", "ok\n");
c->is_draining = 1;
c->label[0] = 'X';
c->data[0] = 'X';
} else if (mg_http_match_uri(hm, "/debug")) {
int level = (int) mg_json_get_long(hm->body, "$.level", MG_LL_DEBUG);
mg_log_set(level);
@@ -991,7 +991,7 @@ static void mg_hfn(struct mg_connection *c, int ev, void *ev_data, void *fnd) {
mg_http_reply(c, 200, "", "hi\n");
}
} else if (ev == MG_EV_CLOSE) {
if (c->label[0] == 'X') *(bool *) fnd = true;
if (c->data[0] == 'X') *(bool *) fnd = true;
}
}