Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Commit

Permalink
use a different monitor to wait for readiness, should fix #481
Browse files Browse the repository at this point in the history
  • Loading branch information
krakjoe committed Sep 8, 2015
1 parent 6907ffd commit b889340
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/object.c
Expand Up @@ -203,6 +203,7 @@ int pthreads_connect(pthreads_object_t* source, pthreads_object_t* destination)
pthreads_stack_free(destination->stack);
}

pthreads_monitor_free(destination->ready);
pthreads_monitor_free(destination->monitor);

destination->scope |= PTHREADS_SCOPE_CONNECTION;
Expand All @@ -214,6 +215,7 @@ int pthreads_connect(pthreads_object_t* source, pthreads_object_t* destination)
destination->local.id = source->local.id;
destination->local.ls = source->local.ls;
destination->monitor = source->monitor;
destination->ready = source->ready;
destination->store = source->store;
destination->stack = source->stack;

Expand Down Expand Up @@ -265,7 +267,8 @@ static void pthreads_base_ctor(pthreads_object_t* base, zend_class_entry *entry)

if (PTHREADS_IS_NOT_CONNECTION(base)) {
base->monitor = pthreads_monitor_alloc();
base->store = pthreads_store_alloc();
base->ready = pthreads_monitor_alloc();
base->store = pthreads_store_alloc();

if (PTHREADS_IS_WORKER(base)) {
base->stack = pthreads_stack_alloc(base->monitor);
Expand Down Expand Up @@ -337,7 +340,7 @@ zend_bool pthreads_start(pthreads_object_t* thread) {

switch (pthread_create(&thread->thread, NULL, pthreads_routine, (void*)thread)) {
case SUCCESS:
pthreads_monitor_wait_until(thread->monitor, PTHREADS_MONITOR_READY);
pthreads_monitor_wait_until(thread->ready, PTHREADS_MONITOR_READY);
return 1;

case EAGAIN:
Expand Down
4 changes: 2 additions & 2 deletions src/prepare.c
Expand Up @@ -574,7 +574,7 @@ static inline void pthreads_prepare_sapi(pthreads_object_t* thread) {

#ifdef PTHREADS_KILL_SIGNAL
static inline void pthreads_kill_handler(int signo) /* {{{ */
{
{
ZEND_TSRMLS_CACHE_UPDATE();

pthreads_object_t* current = PTHREADS_FETCH_FROM(Z_OBJ(PTHREADS_ZG(this)));
Expand Down Expand Up @@ -629,7 +629,7 @@ int pthreads_prepared_startup(pthreads_object_t* thread) {
pthreads_prepare_exception_handler(thread);
pthreads_prepare_resource_destructor(thread);

pthreads_monitor_add(thread->monitor, PTHREADS_MONITOR_READY);
pthreads_monitor_add(thread->ready, PTHREADS_MONITOR_READY);

return SUCCESS;
} /* }}} */
Expand Down
1 change: 1 addition & 0 deletions src/thread.h
Expand Up @@ -37,6 +37,7 @@ typedef struct _pthreads_object_t {
uint scope;
zend_ulong options;
pthreads_monitor_t *monitor;
pthreads_monitor_t *ready;
pthreads_store_t *store;
pthreads_stack_t *stack;
pthreads_ident_t creator;
Expand Down

0 comments on commit b889340

Please sign in to comment.