Skip to content

Commit

Permalink
Make acl_fiber_kill() more safety.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Jan 26, 2024
1 parent 57a944a commit ae87f9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib_acl/src/master/template/acl_aio_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -925,9 +925,9 @@ static void dispatch_receive(int event_type acl_unused, ACL_EVENT *event,

ret = acl_read_fd(ACL_VSTREAM_SOCK(conn), buf, sizeof(buf) - 1, &fd);
if (ret <= 0 || fd < 0) {
acl_msg_warn("%s(%d), %s: read from master_dispatch(%s) error",
acl_msg_warn("%s(%d), %s: read from master_dispatch(%s) error %s",
__FUNCTION__, __LINE__, myname,
acl_var_aio_dispatch_addr);
acl_var_aio_dispatch_addr, acl_last_serror());

acl_event_disable_read(event, conn);
acl_vstream_close(conn);
Expand Down
6 changes: 4 additions & 2 deletions lib_fiber/c/src/fiber_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,10 @@ static void read_callback(EVENT *ev, FILE_EVENT *fe)
/* If the reader fiber has been set in ready status when the
* other fiber killed the reader fiber, the reader fiber should
* not be set in ready queue again.
* We should check if fe->fiber_r is NULL, which maybe set NULL if
* the other fiber acl_fiber_kill() the fiber_r before.
*/
if (fe->fiber_r->status != FIBER_STATUS_READY) {
if (fe->fiber_r && fe->fiber_r->status != FIBER_STATUS_READY) {
acl_fiber_ready(fe->fiber_r);
}
}
Expand Down Expand Up @@ -497,7 +499,7 @@ static void write_callback(EVENT *ev, FILE_EVENT *fe)
* other fiber killed the writer fiber, the writer fiber should
* not be set in ready queue again.
*/
if (fe->fiber_w->status != FIBER_STATUS_READY) {
if (fe->fiber_w && fe->fiber_w->status != FIBER_STATUS_READY) {
acl_fiber_ready(fe->fiber_w);
}
}
Expand Down

0 comments on commit ae87f9e

Please sign in to comment.