Call MG_EV_ERROR with c->is_closing set

This commit is contained in:
Sergey Lyubka 2021-12-15 11:31:42 +00:00
parent aa6d8b4662
commit d0a6c111cb
2 changed files with 4 additions and 4 deletions

View File

@ -399,9 +399,9 @@ void mg_error(struct mg_connection *c, const char *fmt, ...) {
mg_vasprintf(&buf, sizeof(mem), fmt, ap);
va_end(ap);
LOG(LL_ERROR, ("%lu %s", c->id, buf));
mg_call(c, MG_EV_ERROR, buf);
c->is_closing = 1; // Set is_closing before sending MG_EV_CALL
mg_call(c, MG_EV_ERROR, buf); // Let user handler to override it
if (buf != mem) free(buf);
c->is_closing = 1;
}
#ifdef MG_ENABLE_LINES

View File

@ -18,7 +18,7 @@ void mg_error(struct mg_connection *c, const char *fmt, ...) {
mg_vasprintf(&buf, sizeof(mem), fmt, ap);
va_end(ap);
LOG(LL_ERROR, ("%lu %s", c->id, buf));
mg_call(c, MG_EV_ERROR, buf);
c->is_closing = 1; // Set is_closing before sending MG_EV_CALL
mg_call(c, MG_EV_ERROR, buf); // Let user handler to override it
if (buf != mem) free(buf);
c->is_closing = 1;
}