Skip to content

Commit d365b6b

Browse files
committed
1 parent a11aa99 commit d365b6b

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

ext-src/swoole_process_pool.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,7 @@ static PHP_METHOD(swoole_process_pool, __construct) {
334334
pool->main_loop = nullptr;
335335
} else {
336336
if (ipc_type > 0) {
337-
if (pool->set_protocol(0, SW_INPUT_BUFFER_SIZE) < 0) {
338-
zend_throw_exception_ex(swoole_exception_ce, errno, "failed to create process pool");
339-
RETURN_FALSE;
340-
}
337+
pool->set_protocol(0, SW_INPUT_BUFFER_SIZE);
341338
}
342339
}
343340

@@ -360,9 +357,18 @@ static PHP_METHOD(swoole_process_pool, set) {
360357

361358
ProcessPoolProperty *pp = php_swoole_process_pool_get_and_check_pp(ZEND_THIS);
362359

360+
php_swoole_set_global_option(vht);
361+
php_swoole_set_coroutine_option(vht);
362+
php_swoole_set_aio_option(vht);
363+
363364
if (php_swoole_array_get_value(vht, "enable_coroutine", ztmp)) {
364365
pp->enable_coroutine = zval_is_true(ztmp);
365366
}
367+
368+
ProcessPool *pool = php_swoole_process_pool_get_and_check_pool(ZEND_THIS);
369+
if (pp->enable_coroutine) {
370+
pool->main_loop = nullptr;
371+
}
366372
}
367373

368374
static PHP_METHOD(swoole_process_pool, on) {

include/swoole_process_pool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ struct ProcessPool {
261261

262262
void set_max_request(uint32_t _max_request, uint32_t _max_request_grace);
263263
int get_max_request();
264-
int set_protocol(int task_protocol, uint32_t max_packet_size);
264+
void set_protocol(int task_protocol, uint32_t max_packet_size);
265265
bool detach();
266266
int wait();
267267
int start();

src/os/process_pool.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static int ProcessPool_worker_loop(ProcessPool *pool, Worker *worker) {
497497
return SW_OK;
498498
}
499499

500-
int ProcessPool::set_protocol(int task_protocol, uint32_t max_packet_size) {
500+
void ProcessPool::set_protocol(int task_protocol, uint32_t max_packet_size) {
501501
if (task_protocol) {
502502
main_loop = ProcessPool_worker_loop;
503503
} else {
@@ -508,8 +508,6 @@ int ProcessPool::set_protocol(int task_protocol, uint32_t max_packet_size) {
508508
max_packet_size_ = max_packet_size;
509509
main_loop = ProcessPool_worker_loop_ex;
510510
}
511-
512-
return SW_OK;
513511
}
514512

515513
static int ProcessPool_worker_loop_ex(ProcessPool *pool, Worker *worker) {

0 commit comments

Comments
 (0)