Fix #1520 - move state to struct mg_mgr

This commit is contained in:
Sergey Lyubka committed 2022-04-12 14:14:55 +01:00
1 parent 66376885e9
commit ef44f90491
24 files changed
+218 -276

No files matched your search

+4 -4
View File
@@ -13,16 +13,16 @@
// The very first web page in history. You can replace it from command line
static const char *s_url = "http://info.cern.ch/";
static const char *s_post_data = NULL; // POST data
static const int64_t s_timeout_ms = 1500; // Connect timeout in milliseconds
static const char *s_post_data = NULL; // POST data
static const uint64_t s_timeout_ms = 1500; // Connect timeout in milliseconds
// Print HTTP response and signal that we're done
static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
if (ev == MG_EV_OPEN) {
// Connection created. Store connect expiration time in c->label
*(int64_t *) c->label = mg_millis() + s_timeout_ms;
*(uint64_t *) c->label = mg_millis() + s_timeout_ms;
} else if (ev == MG_EV_POLL) {
if (mg_millis() > *(int64_t *) c->label &&
if (mg_millis() > *(uint64_t *) c->label &&
(c->is_connecting || c->is_resolving)) {
mg_error(c, "Connect timeout");
}