Browse Source

Handle cases, where not all threads could be created

bel 10 years ago
parent
commit
c2ac66c7a2
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/civetweb.c

+ 2 - 1
src/civetweb.c

@@ -2139,7 +2139,7 @@ static int mg_start_thread_with_id(mg_thread_func_t func, void *param, pthread_t
 
     result = pthread_create(&thread_id, &attr, func, param);
     pthread_attr_destroy(&attr);
-    if (threadidptr != NULL) {
+    if ((result == 0) && (threadidptr != NULL)) {
         *threadidptr = thread_id;
     }
     return result;
@@ -7300,6 +7300,7 @@ struct mg_context *mg_start(const struct mg_callbacks *callbacks,
             ctx->num_threads--;
             (void) pthread_mutex_unlock(&ctx->thread_mutex);
             mg_cry(fc(ctx), "Cannot start worker thread: %ld", (long) ERRNO);
+            break;
         }
     }