summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2014-07-09 09:53:58 +0200
committerRemi Collet <fedora@famillecollet.com>2014-07-09 09:53:58 +0200
commiteb22e426f28751c71036a18df035c956e8de07f7 (patch)
treee4b7cf96f49ff2d35af6cdef387492c8ca149ad2
parent37ab090b9aa4d510c7bf9048d304874b144f6f05 (diff)
php-pecl-sync: wip
-rw-r--r--sync-build.patch55
1 files changed, 55 insertions, 0 deletions
diff --git a/sync-build.patch b/sync-build.patch
new file mode 100644
index 0000000..910c3f4
--- /dev/null
+++ b/sync-build.patch
@@ -0,0 +1,55 @@
+diff --git a/sync.c b/sync.c
+index 016c636..f8344bd 100644
+--- a/sync.c
++++ b/sync.c
+@@ -22,5 +22,10 @@
+ #include "php_sync.h"
+
++/* PHP_FE_END not define in php < 5.3.7 */
++#ifndef PHP_FE_END
++#define PHP_FE_END {NULL, NULL, NULL}
++#endif
++
+ /* {{{ sync_module_entry
+ */
+ zend_module_entry sync_module_entry = {
+diff --git a/config.m4 b/config.m4
+index a386835..877bb61 100644
+--- a/config.m4
++++ b/config.m4
+@@ -23,6 +23,9 @@ if test "$PHP_SYNC" != "no"; then
+ AC_MSG_ERROR([sem_open() is not available on this platform])
+ ])
+
++ PHP_ADD_LIBRARY(rt,,SYNC_SHARED_LIBADD)
++ PHP_SUBST(SYNC_SHARED_LIBADD)
++
+ dnl # Finish defining the basic extension support.
+ AC_DEFINE(HAVE_SYNC, 1, [Whether you have synchronization object support])
+ PHP_NEW_EXTENSION(sync, sync.c, $ext_shared)
+diff --git a/sync.c b/sync.c
+index 529133a..40fe075 100644
+--- a/sync.c
++++ b/sync.c
+@@ -1120,11 +1120,17 @@ int sync_ReaderWriter_readunlock_internal(sync_ReaderWriter_object *obj)
+ if (!sync_WaitForSemaphore(obj->MxSemRSemMutex, INFINITE)) return 0;
+
+ /* Release the semaphore. */
+- Result = sem_post(obj->MxSemRSemaphore);
+-
+- /* Update the event state. */
+ sem_getvalue(obj->MxSemRSemaphore, &Val);
+- if (Val == SEM_VALUE_MAX) sem_post(obj->MxSemRWaitEvent);
++ if (Val == SEM_VALUE_MAX) {
++ Result = 1;
++ sem_post(obj->MxSemRWaitEvent);
++ } else {
++ Result = sem_post(obj->MxSemRSemaphore);
++
++ /* Update the event state. */
++ sem_getvalue(obj->MxSemRSemaphore, &Val);
++ if (Val == SEM_VALUE_MAX) sem_post(obj->MxSemRWaitEvent);
++ }
+
+ if (obj->MxReadLocks) obj->MxReadLocks--;
+