[PATCH] lib: Fix thread management in thread pool manager

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Mon, 16 Mar 2020 17:47:02 +0100

The thread pool manager wasn't counting working threads when deciding
to create new ones, resulting in constant starting of new threads when
threads were busy.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
---
 src/lib/tpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lib/tpm.c b/src/lib/tpm.c
index 0ba9619..ff0a22d 100644
--- a/src/lib/tpm.c
+++ b/src/lib/tpm.c
@@ -159,7 +159,7 @@ static void * tpmgr(void * o)
 
                 if (pthread_cond_timedwait(&tpm->cond, &tpm->lock, &dl)
                     == ETIMEDOUT)
-                        if (tpm->cur > tpm->min)
+                        if (tpm->cur - tpm->wrk > tpm->min)
                                 tpm_kill(tpm);
 
                 pthread_mutex_unlock(&tpm->lock);
-- 
2.25.1


Other related posts:

  • » [PATCH] lib: Fix thread management in thread pool manager - Dimitri Staessens