Parcourir la source

Reset user connection data when closing the connection

bel2125 il y a 8 ans
Parent
commit
125cc06a8b
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      src/civetweb.c

+ 5 - 0
src/civetweb.c

@@ -14193,6 +14193,11 @@ close_connection(struct mg_connection *conn)
 		conn->ctx->callbacks.connection_close(conn);
 		conn->ctx->callbacks.connection_close(conn);
 	}
 	}
 
 
+	/* Reset user data, after close callback is called.
+	 * Do not reuse it. If the user needs a destructor,
+	 * it must be done in the connection_close callback. */
+	mg_set_user_connection_data(conn, NULL);
+
 	mg_lock_connection(conn);
 	mg_lock_connection(conn);
 
 
 	conn->must_close = 1;
 	conn->must_close = 1;