From 356f1f51191aab4d1cbab5e53ffa8681ca6edc5c Mon Sep 17 00:00:00 2001 From: Alexander Alashkin Date: Tue, 29 Mar 2016 11:30:16 +0100 Subject: [PATCH] Fix connection reuse in mg_if_recv_udp_cb PUBLISHED_FROM=5d248fd465ade7f42293611bc2d60ed72439a489 --- mongoose.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mongoose.c b/mongoose.c index 31ec44e1..33e9055d 100644 --- a/mongoose.c +++ b/mongoose.c @@ -2684,19 +2684,20 @@ void mg_if_recv_udp_cb(struct mg_connection *nc, void *buf, int len, struct mg_add_sock_opts opts; memset(&opts, 0, sizeof(opts)); nc = mg_create_connection(lc->mgr, lc->handler, opts); - } - if (nc != NULL) { - nc->sock = lc->sock; - nc->listener = lc; - nc->sa = *sa; - nc->proto_handler = lc->proto_handler; - nc->user_data = lc->user_data; - nc->recv_mbuf_limit = lc->recv_mbuf_limit; - nc->flags = MG_F_UDP; - mg_add_conn(lc->mgr, nc); - mg_call(nc, NULL, MG_EV_ACCEPT, &nc->sa); - } else { - DBG(("OOM")); + if (nc != NULL) { + nc->sock = lc->sock; + nc->listener = lc; + nc->sa = *sa; + nc->proto_handler = lc->proto_handler; + nc->user_data = lc->user_data; + nc->recv_mbuf_limit = lc->recv_mbuf_limit; + nc->flags = MG_F_UDP; + mg_add_conn(lc->mgr, nc); + mg_call(nc, NULL, MG_EV_ACCEPT, &nc->sa); + } else { + DBG(("OOM")); + /* No return here, we still need to drop on the floor */ + } } } if (nc != NULL) {