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

Commit

Permalink
remove running when a thread is killed
Browse files Browse the repository at this point in the history
  • Loading branch information
krakjoe committed Sep 8, 2015
1 parent 3d72793 commit c84403d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion classes/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ PHP_METHOD(Thread, kill)
if (zend_parse_parameters_none() != SUCCESS) {
return;
}


if (!pthreads_monitor_check(thread->monitor, PTHREADS_MONITOR_STARTED)) {
return;
}

RETURN_BOOL(pthread_kill(thread->thread, PTHREADS_KILL_SIGNAL)==SUCCESS);
} /* }}} */

Expand Down
5 changes: 3 additions & 2 deletions src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,16 @@ static inline zend_bool pthreads_routine_run_function(pthreads_object_t* object,
call.fcc.calling_scope = connection->std.ce;
call.fcc.called_scope = connection->std.ce;
call.fcc.function_handler = run;

zend_call_function(&call.fci, &call.fcc);
}
}
} zend_catch {
pthreads_monitor_add(object->monitor, PTHREADS_MONITOR_ERROR);

if (PTHREADS_ZG(signal) == PTHREADS_KILL_SIGNAL) {
/* like, totally bail man ! */
pthreads_monitor_remove(
object->monitor, PTHREADS_MONITOR_RUNNING);
zend_bailout();
}
} zend_end_try();
Expand Down

0 comments on commit c84403d

Please sign in to comment.