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

Loading…
Cancel
Save