mongoose/src/event.c

22 lines
563 B
C
Raw Normal View History

2020-12-05 19:26:32 +08:00
#include "event.h"
#include "log.h"
#include "net.h"
#include "util.h"
void mg_call(struct mg_connection *c, int ev, void *ev_data) {
if (c->pfn != NULL) c->pfn(c, ev, ev_data, c->pfn_data);
if (c->fn != NULL) c->fn(c, ev, ev_data, c->fn_data);
}
void mg_error(struct mg_connection *c, const char *fmt, ...) {
char mem[256], *buf = mem;
va_list ap;
va_start(ap, fmt);
mg_vasprintf(&buf, sizeof(mem), fmt, ap);
va_end(ap);
2020-12-21 20:26:44 +08:00
LOG(LL_ERROR, ("%lu %s", c->id, buf));
2020-12-05 19:26:32 +08:00
mg_call(c, MG_EV_ERROR, buf);
if (buf != mem) free(buf);
c->is_closing = 1;
}