Skip to content

Commit 6732ba6

Browse files
committed
Merge branch 'master' of github.com:swoole/swoole-src
2 parents d365b6b + 844191b commit 6732ba6

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

core-tests/src/server/server.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,38 @@ TEST(server, create_pipe_buffers) {
4040
}
4141
}
4242

43+
TEST(server, schedule) {
44+
int ret;
45+
Server serv(Server::MODE_PROCESS);
46+
serv.worker_num = 6;
47+
serv.dispatch_mode = SW_DISPATCH_QUEUE;
48+
ret = serv.create();
49+
ASSERT_EQ(SW_OK, ret);
50+
51+
for (uint32_t i = 0; i < serv.worker_num; i++) {
52+
serv.workers[i].status = SW_WORKER_BUSY;
53+
}
54+
55+
std::set<int> _worker_id_set;
56+
57+
for (uint32_t i = 0; i < serv.worker_num; i++) {
58+
auto worker_id = serv.schedule_worker(i*13, nullptr);
59+
_worker_id_set.insert(worker_id);
60+
}
61+
ASSERT_EQ(_worker_id_set.size(), serv.worker_num);
62+
63+
for (uint32_t i = 1; i < serv.worker_num - 1; i++) {
64+
serv.workers[i].status = SW_WORKER_IDLE;
65+
}
66+
67+
_worker_id_set.clear();
68+
for (uint32_t i = 0; i < serv.worker_num; i++) {
69+
auto worker_id = serv.schedule_worker(i*13, nullptr);
70+
_worker_id_set.insert(worker_id);
71+
}
72+
ASSERT_EQ(_worker_id_set.size(), serv.worker_num - 2);
73+
}
74+
4375
static const char *packet = "hello world\n";
4476

4577
TEST(server, base) {

ext-src/swoole_runtime.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,11 @@ static void hook_func(const char *name, size_t l_name, zif_handler handler, zend
18601860
if (zf == nullptr) {
18611861
return;
18621862
}
1863+
#if PHP_VERSION_ID < 80000
1864+
if (zf->internal_function.handler == ZEND_FN(display_disabled_function)) {
1865+
return;
1866+
}
1867+
#endif
18631868

18641869
rf = (real_func *) emalloc(sizeof(real_func));
18651870
sw_memset_zero(rf, sizeof(*rf));

include/swoole_process_pool.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ struct Worker {
148148
void *ptr2;
149149

150150
ssize_t send_pipe_message(const void *buf, size_t n, int flags);
151+
152+
void set_status(enum swWorker_status _status) {
153+
status = _status;
154+
}
155+
156+
bool is_busy() {
157+
return status == SW_WORKER_BUSY;
158+
}
159+
160+
bool is_idle() {
161+
return status == SW_WORKER_IDLE;
162+
}
151163
};
152164

153165
struct StreamInfo {

0 commit comments

Comments
 (0)