ソースを参照

Fix mg_start_worker_thread() to take the number of socket-connections already enqueued into account when deciding whether or not to spawn a new thread

Jeremy Friesner 2 年 前
コミット
a588b5ffe7
1 ファイル変更1 行追加1 行削除
  1. 1 1
      src/civetweb.c

+ 1 - 1
src/civetweb.c

@@ -20527,7 +20527,7 @@ static int mg_start_worker_thread(struct mg_context *ctx, int only_if_no_idle_th
 	}
 
 	(void)pthread_mutex_lock(&ctx->thread_mutex);
-	if ((only_if_no_idle_threads)&&(ctx->idle_worker_thread_count > 0)) {
+	if ((only_if_no_idle_threads)&&(ctx->idle_worker_thread_count > (unsigned)(ctx->sq_head-ctx->sq_tail))) {
 		(void)pthread_mutex_unlock(&ctx->thread_mutex);
 		return -2;  /* There are idle threads available, so no need to spawn a new worker thread now */
 	}