From 55c27d4751adbb174349b3b68a8cf78ee54a541c Mon Sep 17 00:00:00 2001 From: Thomas Davis Date: Mon, 23 Sep 2013 21:46:41 -0400 Subject: [PATCH] Fixed potential dead-lock in connection_close() This was posted by Morgan McGuire. --- src/civetweb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/civetweb.c b/src/civetweb.c index c83bd96f..d777f3f9 100644 --- a/src/civetweb.c +++ b/src/civetweb.c @@ -5326,12 +5326,12 @@ static void close_socket_gracefully(struct mg_connection *conn) static void close_connection(struct mg_connection *conn) { - mg_lock(conn); - // call the connection_close callback if assigned if (conn->ctx->callbacks.connection_close != NULL) conn->ctx->callbacks.connection_close(conn); + mg_lock(conn); + conn->must_close = 1; #ifndef NO_SSL