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

Loading…
Cancel
Save