Merge branch 'gitee-master' into gitlab-upstream

This commit is contained in:
zhengshuxin 2024-03-28 11:34:51 +08:00
commit 2473c265eb
5 changed files with 24 additions and 22 deletions

View File

@ -346,14 +346,15 @@ int event_add_write(EVENT *ev, FILE_EVENT *fe, event_proc *proc)
return 1; return 1;
} }
void event_del_read(EVENT *ev, FILE_EVENT *fe) void event_del_read(EVENT *ev, FILE_EVENT *fe, int directly)
{ {
if (fe->oper & EVENT_ADD_READ) { if (fe->oper & EVENT_ADD_READ) {
fe->oper &=~EVENT_ADD_READ; fe->oper &=~EVENT_ADD_READ;
} }
if (fe->mask & EVENT_READ) { if (fe->mask & EVENT_READ) {
if (fe->mask & EVENT_DIRECT) { if ((fe->mask & EVENT_DIRECT) || directly) {
ring_detach(&fe->me);
(void) ev->del_read(ev, fe); (void) ev->del_read(ev, fe);
} else if (fe->me.parent == &fe->me) { } else if (fe->me.parent == &fe->me) {
ring_prepend(&ev->events, &fe->me); ring_prepend(&ev->events, &fe->me);
@ -365,14 +366,15 @@ void event_del_read(EVENT *ev, FILE_EVENT *fe)
fe->r_proc = NULL; fe->r_proc = NULL;
} }
void event_del_write(EVENT *ev, FILE_EVENT *fe) void event_del_write(EVENT *ev, FILE_EVENT *fe, int directly)
{ {
if (fe->oper & EVENT_ADD_WRITE) { if (fe->oper & EVENT_ADD_WRITE) {
fe->oper &= ~EVENT_ADD_WRITE; fe->oper &= ~EVENT_ADD_WRITE;
} }
if (fe->mask & EVENT_WRITE) { if (fe->mask & EVENT_WRITE) {
if (fe->mask & EVENT_DIRECT) { if ((fe->mask & EVENT_DIRECT) || directly) {
ring_detach(&fe->me);
(void) ev->del_write(ev, fe); (void) ev->del_write(ev, fe);
} else if (fe->me.parent == &fe->me) { } else if (fe->me.parent == &fe->me) {
ring_prepend(&ev->events, &fe->me); ring_prepend(&ev->events, &fe->me);

View File

@ -441,8 +441,8 @@ int event_checkfd(EVENT *ev, FILE_EVENT *fe);
int event_add_read(EVENT *ev, FILE_EVENT *fe, event_proc *proc); int event_add_read(EVENT *ev, FILE_EVENT *fe, event_proc *proc);
int event_add_write(EVENT *ev, FILE_EVENT *fe, event_proc *proc); int event_add_write(EVENT *ev, FILE_EVENT *fe, event_proc *proc);
void event_del_read(EVENT *ev, FILE_EVENT *fe); void event_del_read(EVENT *ev, FILE_EVENT *fe, int directly);
void event_del_write(EVENT *ev, FILE_EVENT *fe); void event_del_write(EVENT *ev, FILE_EVENT *fe, int directly);
int event_process(EVENT *ev, int left); int event_process(EVENT *ev, int left);
#endif #endif

View File

@ -439,7 +439,7 @@ size_t acl_fiber_sleep(size_t seconds)
static void read_callback(EVENT *ev, FILE_EVENT *fe) static void read_callback(EVENT *ev, FILE_EVENT *fe)
{ {
CLR_READWAIT(fe); CLR_READWAIT(fe);
event_del_read(ev, fe); event_del_read(ev, fe, 0);
/* If the reader fiber has been set in ready status when the /* If the reader fiber has been set in ready status when the
* other fiber killed the reader fiber, the reader fiber should * other fiber killed the reader fiber, the reader fiber should
@ -502,11 +502,11 @@ int fiber_wait_read(FILE_EVENT *fe)
// If the IO has been canceled, we should try to remove the // If the IO has been canceled, we should try to remove the
// IO read event, because the wakeup process wasn't from // IO read event, because the wakeup process wasn't from
// read_callback normally. // read_callback normally.
#if 0 #if 1
// Don't call event_del_read here, because it's a buffered // Don't call event_del_read here, because it's a buffered
// delete read operation; We'll real delete read operation on // delete read operation; We'll real delete read operation on
// the fd in event_close. // the fd in event_close.
event_del_read(__thread_fiber->event, fe); event_del_read(__thread_fiber->event, fe, 1);
#endif #endif
acl_fiber_set_error(curr->errnum); acl_fiber_set_error(curr->errnum);
return -1; return -1;
@ -514,11 +514,11 @@ int fiber_wait_read(FILE_EVENT *fe)
// If the IO reading timeout set in setsockopt. // If the IO reading timeout set in setsockopt.
// Clear FIBER_F_TIMER flag been set in wakeup_timers. // Clear FIBER_F_TIMER flag been set in wakeup_timers.
curr->flag &= ~FIBER_F_TIMER; curr->flag &= ~FIBER_F_TIMER;
#if 0 #if 1
// Don't call event_del_read here, because it's a buffered // Don't call event_del_read here, because it's a buffered
// delete read operation; We'll real delete read operation on // delete read operation; We'll real delete read operation on
// the fd in event_close. // the fd in event_close.
event_del_read(__thread_fiber->event, fe); event_del_read(__thread_fiber->event, fe, 1);
#endif #endif
acl_fiber_set_errno(curr, FIBER_EAGAIN); acl_fiber_set_errno(curr, FIBER_EAGAIN);
@ -533,7 +533,7 @@ int fiber_wait_read(FILE_EVENT *fe)
static void write_callback(EVENT *ev, FILE_EVENT *fe) static void write_callback(EVENT *ev, FILE_EVENT *fe)
{ {
CLR_WRITEWAIT(fe); CLR_WRITEWAIT(fe);
event_del_write(ev, fe); event_del_write(ev, fe, 0);
/* If the writer fiber has been set in ready status when the /* If the writer fiber has been set in ready status when the
* other fiber killed the writer fiber, the writer fiber should * other fiber killed the writer fiber, the writer fiber should
@ -585,15 +585,15 @@ int fiber_wait_write(FILE_EVENT *fe)
} }
if (acl_fiber_canceled(curr)) { if (acl_fiber_canceled(curr)) {
#if 0 #if 1
event_del_write(__thread_fiber->event, fe); event_del_write(__thread_fiber->event, fe, 1);
#endif #endif
acl_fiber_set_error(curr->errnum); acl_fiber_set_error(curr->errnum);
return -1; return -1;
} else if (curr->flag & FIBER_F_TIMER) { } else if (curr->flag & FIBER_F_TIMER) {
curr->flag &= ~FIBER_F_TIMER; curr->flag &= ~FIBER_F_TIMER;
#if 0 #if 1
event_del_write(__thread_fiber->event, fe); event_del_write(__thread_fiber->event, fe, 1);
#endif #endif
acl_fiber_set_errno(curr, FIBER_EAGAIN); acl_fiber_set_errno(curr, FIBER_EAGAIN);

View File

@ -552,13 +552,13 @@ static void epoll_ctl_del(EVENT *ev, EPOLL_EVENT *ee, int fd)
if (epx->mask & EVENT_READ) { if (epx->mask & EVENT_READ) {
assert(epx->fe); assert(epx->fe);
event_del_read(ev, epx->fe); event_del_read(ev, epx->fe, 0);
CLR_READWAIT(epx->fe); CLR_READWAIT(epx->fe);
} }
if (epx->mask & EVENT_WRITE) { if (epx->mask & EVENT_WRITE) {
assert(epx->fe); assert(epx->fe);
event_del_write(ev, epx->fe); event_del_write(ev, epx->fe, 0);
CLR_WRITEWAIT(epx->fe); CLR_WRITEWAIT(epx->fe);
} }

View File

@ -72,7 +72,7 @@ static void read_callback(EVENT *ev, FILE_EVENT *fe)
POLLFD *pfd; POLLFD *pfd;
RING *iter = fe->pfds.succ, *next = iter; RING *iter = fe->pfds.succ, *next = iter;
event_del_read(ev, fe); event_del_read(ev, fe, 0);
SET_READABLE(fe); SET_READABLE(fe);
// Walk througth the RING list, handle each poll event, and one RING // Walk througth the RING list, handle each poll event, and one RING
@ -129,7 +129,7 @@ static void write_callback(EVENT *ev, FILE_EVENT *fe)
POLLFD *pfd; POLLFD *pfd;
RING *iter = fe->pfds.succ, *next = iter; RING *iter = fe->pfds.succ, *next = iter;
event_del_write(ev, fe); event_del_write(ev, fe, 0);
SET_WRITABLE(fe); SET_WRITABLE(fe);
for (; iter != &fe->pfds; iter = next) { for (; iter != &fe->pfds; iter = next) {
@ -209,7 +209,7 @@ static void poll_event_clean(EVENT *ev, POLL_EVENT *pe)
pfd->fe->mask &= ~EVENT_POLLIN; pfd->fe->mask &= ~EVENT_POLLIN;
pfd->fe->r_timeout = -1; pfd->fe->r_timeout = -1;
#endif #endif
event_del_read(ev, pfd->fe); event_del_read(ev, pfd->fe, 0);
pfd->fe->fiber_r = NULL; pfd->fe->fiber_r = NULL;
} }
if (pfd->pfd->events & POLLOUT) { if (pfd->pfd->events & POLLOUT) {
@ -218,7 +218,7 @@ static void poll_event_clean(EVENT *ev, POLL_EVENT *pe)
pfd->fe->mask &= ~EVENT_POLLOUT; pfd->fe->mask &= ~EVENT_POLLOUT;
pfd->fe->w_timeout = -1; pfd->fe->w_timeout = -1;
#endif #endif
event_del_write(ev, pfd->fe); event_del_write(ev, pfd->fe, 0);
pfd->fe->fiber_w = NULL; pfd->fe->fiber_w = NULL;
} }