Browse Source

Fix #29 limiting SHM updates to 1 per second

Yann Weber 4 years ago
parent
commit
9256b383b1
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      src/responder.c

+ 8
- 2
src/responder.c View File

92
 	short idle, busy;
92
 	short idle, busy;
93
 	struct sigaction act;
93
 	struct sigaction act;
94
 	char *statusstr;
94
 	char *statusstr;
95
+	time_t last_update, now;
95
 
96
 
96
 	act.sa_handler = pool_sighandler;
97
 	act.sa_handler = pool_sighandler;
97
 	sigemptyset(&act.sa_mask);
98
 	sigemptyset(&act.sa_mask);
150
 	//Wait at least for a process to be ready
151
 	//Wait at least for a process to be ready
151
 	while(!pyfcgi_pool_idle(&timeout));
152
 	while(!pyfcgi_pool_idle(&timeout));
152
 
153
 
154
+	last_update = 0;
155
+
153
 	// main loop, taking care to restart terminated workers, 
156
 	// main loop, taking care to restart terminated workers, 
154
 	// spawn new one if needed, etc.
157
 	// spawn new one if needed, etc.
155
 	while(1)
158
 	while(1)
156
 	{
159
 	{
157
 		pyfcgi_wd_arm();
160
 		pyfcgi_wd_arm();
158
 		PyFCGI_conf.context.n_wrk = n_wrk;
161
 		PyFCGI_conf.context.n_wrk = n_wrk;
159
-		pyfcgi_pool_shm_update(n_wrk);
162
+		if(last_update != (now = time(NULL)))
163
+		{
164
+			pyfcgi_pool_shm_update(n_wrk);
165
+			last_update = now;
166
+		}
160
 		if( (ret = waitpid(0, &status, WNOHANG)) )
167
 		if( (ret = waitpid(0, &status, WNOHANG)) )
161
 		{
168
 		{
162
 			if(ret < 0)
169
 			if(ret < 0)
505
 	exit(PYFCGI_TIMEOUT);
512
 	exit(PYFCGI_TIMEOUT);
506
 }
513
 }
507
 
514
 
508
-
509
 void pyfcgi_pool_shm_update(int nworker)
515
 void pyfcgi_pool_shm_update(int nworker)
510
 {
516
 {
511
 	short retry;
517
 	short retry;

Loading…
Cancel
Save