Browse Source

Add a todo for a POSIX semaphore problem :'(

Yann Weber 5 years ago
parent
commit
bd6267330a
3 changed files with 15 additions and 4 deletions
  1. 1
    1
      configure.ac
  2. 2
    2
      src/Makefile.am
  3. 12
    1
      src/pyworker.c

+ 1
- 1
configure.ac View File

@@ -35,7 +35,7 @@ else
35 35
 fi
36 36
 
37 37
 if test x"${enable_debug}" = x"yes"; then
38
-	AM_CFLAGS="-Wall -g"
38
+	AM_CFLAGS="-Wall -g -DDEBUG"
39 39
 else
40 40
 	AM_CFLAGS="-Wall -Werror -O2"
41 41
 fi

+ 2
- 2
src/Makefile.am View File

@@ -7,12 +7,12 @@ pyfcgi_LDADD = $(PYTHON_LDFLAGS)
7 7
 # libpyfcgi python module
8 8
 lib_LTLIBRARIES = libpyfcgi.la
9 9
 libpyfcgi_la_SOURCES = python_pyfcgi.c python_ioin.c ipc.c monitor.c
10
-libpyfcgi_la_CFLAGS = $(PYTHON_SO_CFLAGS)
10
+libpyfcgi_la_CFLAGS = $(PYTHON_SO_CFLAGS) $(AM_CFLAGS)
11 11
 libpyfcgi_la_LDFLAGS = $(PYTHON_SO_LDFLAGS)
12 12
 
13 13
 # static librarie for check
14 14
 noinst_LIBRARIES = libpyfcgi.a
15 15
 libpyfcgi_a_SOURCES = logger.c pyworker.c responder.c conf.c pyutils.c python_pyfcgi.c python_ioin.c ipc.c monitor.c
16
-libpyfcgi_a_CFLAGS = $(PYTHON_CFLAGS)
16
+libpyfcgi_a_CFLAGS = $(PYTHON_CFLAGS) $(AM_CFLAGS)
17 17
 
18 18
 

+ 12
- 1
src/pyworker.c View File

@@ -610,11 +610,22 @@ static void worker_set_busy()
610 610
 {
611 611
 	int err;
612 612
 	if(!_worker_idle) { return; }
613
+	/**@todo The pool handler WILL decrement the sem to figure if the pool
614
+	 * is busy -__- Using sem_wait make sure that the worker will be able
615
+	 * to set busy, but it can also freeze if not able to set busy....
616
+	 * sem_timedwait require to get abstime -_- The better way is
617
+	 * maybe to nanosleep 0.01s and retry a sem_trywait... SysV sem are
618
+	 * better T_T
619
+	 */
620
+#ifdef DEBUG
613 621
 	if(sem_trywait(PyFCGI_SEM(SEM_WSTATE).sem) < 0)
622
+#else
623
+	if(sem_wait(PyFCGI_SEM(SEM_WSTATE).sem) < 0)
624
+#endif
614 625
 	{
615 626
 		err = errno;
616 627
 		if(err == EAGAIN)
617
-		{//panic
628
+		{ //panic
618 629
 			pyfcgi_log(LOG_ALERT, "Unable to set busy ! WSTATE sem is allready 0 !!!");
619 630
 			_worker_idle = 0;
620 631
 			return;

Loading…
Cancel
Save