From 22f8d86b052c91e44c23746a40654e3da70e4635 Mon Sep 17 00:00:00 2001 From: Marko Mikulicic <mkm@cesanta.com> Date: Fri, 25 Sep 2015 12:10:39 +0100 Subject: [PATCH] Makes sure send file releases resources on close PUBLISHED_FROM=451d2dd0b55b9fd7dea441a9279f54d0005c97b1 --- mongoose.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mongoose.c b/mongoose.c index f2b628f13..bdb9d5e78 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4030,15 +4030,16 @@ static void http_handler(struct mg_connection *nc, int ev, void *ev_data) { #ifndef MG_DISABLE_HTTP_WEBSOCKET struct mg_str *vec; #endif - /* - * For HTTP messages without Content-Length, always send HTTP message - * before MG_EV_CLOSE message. - */ - if (ev == MG_EV_CLOSE && io->len > 0 && - mg_parse_http(io->buf, io->len, &hm, is_req) > 0) { - hm.message.len = io->len; - hm.body.len = io->buf + io->len - hm.body.p; - nc->handler(nc, is_req ? MG_EV_HTTP_REQUEST : MG_EV_HTTP_REPLY, &hm); + if (ev == MG_EV_CLOSE) { + /* + * For HTTP messages without Content-Length, always send HTTP message + * before MG_EV_CLOSE message. + */ + if (io->len > 0 && mg_parse_http(io->buf, io->len, &hm, is_req) > 0) { + hm.message.len = io->len; + hm.body.len = io->buf + io->len - hm.body.p; + nc->handler(nc, is_req ? MG_EV_HTTP_REQUEST : MG_EV_HTTP_REPLY, &hm); + } free_http_proto_data(nc); } -- GitLab