Browse Source

Add a todo for a POSIX semaphore problem :'(

Yann Weber 4 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
 fi
35
 fi
36
 
36
 
37
 if test x"${enable_debug}" = x"yes"; then
37
 if test x"${enable_debug}" = x"yes"; then
38
-	AM_CFLAGS="-Wall -g"
38
+	AM_CFLAGS="-Wall -g -DDEBUG"
39
 else
39
 else
40
 	AM_CFLAGS="-Wall -Werror -O2"
40
 	AM_CFLAGS="-Wall -Werror -O2"
41
 fi
41
 fi

+ 2
- 2
src/Makefile.am View File

7
 # libpyfcgi python module
7
 # libpyfcgi python module
8
 lib_LTLIBRARIES = libpyfcgi.la
8
 lib_LTLIBRARIES = libpyfcgi.la
9
 libpyfcgi_la_SOURCES = python_pyfcgi.c python_ioin.c ipc.c monitor.c
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
 libpyfcgi_la_LDFLAGS = $(PYTHON_SO_LDFLAGS)
11
 libpyfcgi_la_LDFLAGS = $(PYTHON_SO_LDFLAGS)
12
 
12
 
13
 # static librarie for check
13
 # static librarie for check
14
 noinst_LIBRARIES = libpyfcgi.a
14
 noinst_LIBRARIES = libpyfcgi.a
15
 libpyfcgi_a_SOURCES = logger.c pyworker.c responder.c conf.c pyutils.c python_pyfcgi.c python_ioin.c ipc.c monitor.c
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
 {
610
 {
611
 	int err;
611
 	int err;
612
 	if(!_worker_idle) { return; }
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
 	if(sem_trywait(PyFCGI_SEM(SEM_WSTATE).sem) < 0)
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
 		err = errno;
626
 		err = errno;
616
 		if(err == EAGAIN)
627
 		if(err == EAGAIN)
617
-		{//panic
628
+		{ //panic
618
 			pyfcgi_log(LOG_ALERT, "Unable to set busy ! WSTATE sem is allready 0 !!!");
629
 			pyfcgi_log(LOG_ALERT, "Unable to set busy ! WSTATE sem is allready 0 !!!");
619
 			_worker_idle = 0;
630
 			_worker_idle = 0;
620
 			return;
631
 			return;

Loading…
Cancel
Save