From 4927195ee45ce5c15e9cccb6213033feef12f40b Mon Sep 17 00:00:00 2001 From: Alexander Alashkin <alexander.alashkin@cesanta.com> Date: Tue, 8 Mar 2016 12:49:16 +0200 Subject: [PATCH] Use mongoose event to free updater resources PUBLISHED_FROM=3044287fe2623b591ddbf5c619398c21d6753411 --- mongoose.c | 5 +++-- mongoose.h | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mongoose.c b/mongoose.c index f01f63869..625606165 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5072,15 +5072,16 @@ void mg_http_handler(struct mg_connection *nc, int ev, void *ev_data) { */ struct mg_http_stream_info si; struct mg_http_multipart_part mp; + mg_event_handler_t handler; memset(&mp, 0, sizeof(mp)); mg_http_parse_stream_info(&pd->strm_state, &si); + handler = mg_http_get_endpoint_handler(nc->listener, &si.endpoint); mp.status = -1; mp.var_name = si.var_name.p; mp.file_name = si.file_name.p; - mg_call(nc, pd->endpoint_handler ? pd->endpoint_handler : nc->handler, - MG_EV_HTTP_PART_END, &mp); + mg_call(nc, (handler ? handler : nc->handler), MG_EV_HTTP_PART_END, &mp); } else #endif if (io->len > 0 && mg_parse_http(io->buf, io->len, hm, is_req) > 0) { diff --git a/mongoose.h b/mongoose.h index 0be5c4bab..a48e37381 100644 --- a/mongoose.h +++ b/mongoose.h @@ -134,8 +134,10 @@ #endif #include <assert.h> +#include <direct.h> #include <errno.h> #include <fcntl.h> +#include <io.h> #include <limits.h> #include <signal.h> #include <stddef.h> @@ -143,8 +145,6 @@ #include <stdlib.h> #include <sys/stat.h> #include <time.h> -#include <direct.h> -#include <io.h> #define random() rand() #ifdef _MSC_VER @@ -839,7 +839,7 @@ const char *c_strnstr(const char *s, const char *find, size_t slen); !(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809L) && \ !(defined(__DARWIN_C_LEVEL) && __DARWIN_C_LEVEL >= 200809L) && \ !defined(RTOS_SDK)) && \ - !(defined(_MSC_VER) && _MSC_VER >= 1600 /* MSVC2013+ has strnlen */) + !(defined(_MSC_VER) && _MSC_VER >= 1600 /* MSVC2010+ has strnlen */) #define _MG_PROVIDE_STRNLEN size_t strnlen(const char *s, size_t maxlen); #endif -- GitLab