[Groonga-commit] groonga/groonga at 8156048 [master] groonga: fix a bug that thread_limit?max=1 may not reduce N threads

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Dec 9 12:18:21 JST 2015


Kouhei Sutou	2015-12-09 12:18:21 +0900 (Wed, 09 Dec 2015)

  New Revision: 815604839ced9b3ca1967b91d742e642550aa321
  https://github.com/groonga/groonga/commit/815604839ced9b3ca1967b91d742e642550aa321

  Message:
    groonga: fix a bug that thread_limit?max=1 may not reduce N threads

  Modified files:
    src/groonga.c

  Modified: src/groonga.c (+6 -4)
===================================================================
--- src/groonga.c    2015-12-09 11:54:31 +0900 (a6610d0)
+++ src/groonga.c    2015-12-09 12:18:21 +0900 (6184704)
@@ -1954,7 +1954,8 @@ h_worker(void *arg)
   MUTEX_LOCK_ENSURE(ctx, q_mutex);
   GRN_LOG(&grn_gctx, GRN_LOG_NOTICE, "thread start (%d/%d)",
           n_floating_threads, n_running_threads);
-  do {
+  while (n_running_threads <= max_n_floating_threads &&
+         grn_gctx.stat != GRN_CTX_QUIT) {
     grn_obj *msg;
     n_floating_threads++;
     while (!(msg = (grn_obj *)grn_com_queue_deque(&grn_gctx, &ctx_new))) {
@@ -1975,7 +1976,7 @@ h_worker(void *arg)
     hc.is_chunked = GRN_FALSE;
     do_htreq(ctx, (grn_msg *)msg);
     MUTEX_LOCK_ENSURE(ctx, q_mutex);
-  } while (n_floating_threads < max_n_floating_threads && grn_gctx.stat != GRN_CTX_QUIT);
+  };
 exit :
   n_running_threads--;
   GRN_LOG(&grn_gctx, GRN_LOG_NOTICE, "thread end (%d/%d)",
@@ -2040,7 +2041,8 @@ g_worker(void *arg)
   MUTEX_LOCK_ENSURE(NULL, q_mutex);
   GRN_LOG(&grn_gctx, GRN_LOG_NOTICE, "thread start (%d/%d)",
           n_floating_threads, n_running_threads);
-  do {
+   while (n_running_threads <= max_n_floating_threads &&
+          grn_gctx.stat != GRN_CTX_QUIT) {
     grn_ctx *ctx;
     grn_edge *edge;
     n_floating_threads++;
@@ -2095,7 +2097,7 @@ g_worker(void *arg)
     } else {
       edge->stat = EDGE_IDLE;
     }
-  } while (n_floating_threads < max_n_floating_threads && grn_gctx.stat != GRN_CTX_QUIT);
+  };
 exit :
   n_running_threads--;
   GRN_LOG(&grn_gctx, GRN_LOG_NOTICE, "thread end (%d/%d)",
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index