Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Dec 27, 2024
1 parent 9ba82d3 commit da82a6f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion ext-src/php_swoole_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,13 @@ static inline bool sw_is_main_thread() {
#endif
}

size_t sw_get_active_thread_count(void);
#ifdef SW_THREAD
size_t sw_active_thread_count(void);
#else
static inline size_t sw_active_thread_count(void) {
return 1;
}
#endif
void sw_php_exit(int status);

//----------------------------------Constant API------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion ext-src/swoole_runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ bool PHPCoroutine::enable_hook(uint32_t flags) {
* the main thread can only make changes when there are no active worker threads.
*/
if (sw_is_main_thread()) {
if (sw_get_active_thread_count() > 1) {
if (sw_active_thread_count() > 1) {
zend_throw_exception(swoole_exception_ce,
"The stream runtime hook must be enabled or disabled only when "
"there are no active threads.",
Expand Down
6 changes: 3 additions & 3 deletions ext-src/swoole_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ void php_swoole_thread_rshutdown() {
if (!tsrm_is_main_thread()) {
return;
}
if (sw_get_active_thread_count() > 1) {
if (sw_active_thread_count() > 1) {
swoole_warning("Fatal Error: %zu active threads are running, cannot exit safely.",
sw_get_active_thread_count());
sw_active_thread_count());
exit(200);
}
if (request_info.path_translated) {
Expand Down Expand Up @@ -507,7 +507,7 @@ int php_swoole_thread_get_exit_status(pthread_t ptid) {
return thread_exit_status.get(ptid);
}

size_t sw_get_active_thread_count(void) {
size_t sw_active_thread_count(void) {
return thread_num.load();
}

Expand Down

0 comments on commit da82a6f

Please sign in to comment.