Browse Source

Bugfix for worker creation with small execution time

When running dummy scripts the sem_timedwait was unable to detect that the
pool was busy...
Yann Weber 4 years ago
parent
commit
f2c44b9b6d
1 changed files with 6 additions and 5 deletions
  1. 6
    5
      src/responder.c

+ 6
- 5
src/responder.c View File

@@ -86,6 +86,7 @@ int responder_loop()
86 86
 	pid_t ret;
87 87
 	/**@brief poll timeout */
88 88
 	struct timespec timeout;
89
+	struct timespec idle_timeout;
89 90
 	/**@brief watchdog timeout */
90 91
 	struct timespec pool_timeout;
91 92
 	time_t idle_start, busy_start;
@@ -108,8 +109,10 @@ int responder_loop()
108 109
 		exit(PYFCGI_FATAL);
109 110
 	}
110 111
 
112
+	idle_timeout.tv_sec = 0;
113
+	idle_timeout.tv_nsec = 100000; //0.0001s
111 114
 	timeout.tv_sec = 0;
112
-	timeout.tv_nsec = 100000000;
115
+	timeout.tv_nsec = 100000000; //0.1s
113 116
 	idle = busy = 0;
114 117
 
115 118
 	pyfcgi_logger_set_ident("Workpool");
@@ -149,7 +152,7 @@ int responder_loop()
149 152
 		PyFCGI_conf.context.n_wrk = n_wrk;
150 153
 	}
151 154
 	//Wait at least for a process to be ready
152
-	while(!pyfcgi_pool_idle(&timeout));
155
+	while(!pyfcgi_pool_idle(&idle_timeout));
153 156
 
154 157
 	last_update = 0;
155 158
 
@@ -219,12 +222,10 @@ int responder_loop()
219 222
 			// respawn on same slot
220 223
 			pyfcgi_log(LOG_DEBUG, "respawning worker #%d", n);
221 224
 			wrk_pids[n] = spawn(n);
222
-
223
-			continue;
224 225
 		}
225 226
 
226 227
 		// Check if the pool is idle or busy
227
-		if(pyfcgi_pool_idle(&timeout))
228
+		if(pyfcgi_pool_idle(&idle_timeout))
228 229
 		{
229 230
 			// workers idle
230 231
 			busy = 0;

Loading…
Cancel
Save