Bläddra i källkod

Free mutex and condition variables if mg_start fails

bel 11 år sedan
förälder
incheckning
ff23e535fb
1 ändrade filer med 6 tillägg och 6 borttagningar
  1. 6 6
      src/civetweb.c

+ 6 - 6
src/civetweb.c

@@ -6521,12 +6521,6 @@ static void master_thread_run(void *thread_func_param)
         mg_join_thread(ctx->workerthreadids[i]);
         mg_join_thread(ctx->workerthreadids[i]);
     }
     }
 
 
-    /* All threads exited, no sync is needed. Destroy mutex and condvars */
-    (void) pthread_mutex_destroy(&ctx->mutex);
-    (void) pthread_cond_destroy(&ctx->cond);
-    (void) pthread_cond_destroy(&ctx->sq_empty);
-    (void) pthread_cond_destroy(&ctx->sq_full);
-
 #if !defined(NO_SSL)
 #if !defined(NO_SSL)
     uninitialize_ssl(ctx);
     uninitialize_ssl(ctx);
 #endif
 #endif
@@ -6567,6 +6561,12 @@ static void free_context(struct mg_context *ctx)
     if (ctx == NULL)
     if (ctx == NULL)
         return;
         return;
 
 
+    /* All threads exited, no sync is needed. Destroy mutex and condvars */
+    (void) pthread_mutex_destroy(&ctx->mutex);
+    (void) pthread_cond_destroy(&ctx->cond);
+    (void) pthread_cond_destroy(&ctx->sq_empty);
+    (void) pthread_cond_destroy(&ctx->sq_full);
+
     /* Deallocate config parameters */
     /* Deallocate config parameters */
     for (i = 0; i < NUM_OPTIONS; i++) {
     for (i = 0; i < NUM_OPTIONS; i++) {
         if (ctx->config[i] != NULL)
         if (ctx->config[i] != NULL)