mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-13 16:35:35 +08:00
Merge branch 'gitee-master' into gitlab-upstream
This commit is contained in:
commit
2473c265eb
@ -346,14 +346,15 @@ int event_add_write(EVENT *ev, FILE_EVENT *fe, event_proc *proc)
|
||||
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) {
|
||||
fe->oper &=~EVENT_ADD_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);
|
||||
} else if (fe->me.parent == &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;
|
||||
}
|
||||
|
||||
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) {
|
||||
fe->oper &= ~EVENT_ADD_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);
|
||||
} else if (fe->me.parent == &fe->me) {
|
||||
ring_prepend(&ev->events, &fe->me);
|
||||
|
@ -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_write(EVENT *ev, FILE_EVENT *fe, event_proc *proc);
|
||||
|
||||
void event_del_read(EVENT *ev, FILE_EVENT *fe);
|
||||
void event_del_write(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, int directly);
|
||||
int event_process(EVENT *ev, int left);
|
||||
|
||||
#endif
|
||||
|
@ -439,7 +439,7 @@ size_t acl_fiber_sleep(size_t seconds)
|
||||
static void read_callback(EVENT *ev, FILE_EVENT *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
|
||||
* 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
|
||||
// IO read event, because the wakeup process wasn't from
|
||||
// read_callback normally.
|
||||
#if 0
|
||||
#if 1
|
||||
// Don't call event_del_read here, because it's a buffered
|
||||
// delete read operation; We'll real delete read operation on
|
||||
// the fd in event_close.
|
||||
event_del_read(__thread_fiber->event, fe);
|
||||
event_del_read(__thread_fiber->event, fe, 1);
|
||||
#endif
|
||||
acl_fiber_set_error(curr->errnum);
|
||||
return -1;
|
||||
@ -514,11 +514,11 @@ int fiber_wait_read(FILE_EVENT *fe)
|
||||
// If the IO reading timeout set in setsockopt.
|
||||
// Clear FIBER_F_TIMER flag been set in wakeup_timers.
|
||||
curr->flag &= ~FIBER_F_TIMER;
|
||||
#if 0
|
||||
#if 1
|
||||
// Don't call event_del_read here, because it's a buffered
|
||||
// delete read operation; We'll real delete read operation on
|
||||
// the fd in event_close.
|
||||
event_del_read(__thread_fiber->event, fe);
|
||||
event_del_read(__thread_fiber->event, fe, 1);
|
||||
#endif
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
* 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 0
|
||||
event_del_write(__thread_fiber->event, fe);
|
||||
#if 1
|
||||
event_del_write(__thread_fiber->event, fe, 1);
|
||||
#endif
|
||||
acl_fiber_set_error(curr->errnum);
|
||||
return -1;
|
||||
} else if (curr->flag & FIBER_F_TIMER) {
|
||||
curr->flag &= ~FIBER_F_TIMER;
|
||||
#if 0
|
||||
event_del_write(__thread_fiber->event, fe);
|
||||
#if 1
|
||||
event_del_write(__thread_fiber->event, fe, 1);
|
||||
#endif
|
||||
|
||||
acl_fiber_set_errno(curr, FIBER_EAGAIN);
|
||||
|
@ -552,13 +552,13 @@ static void epoll_ctl_del(EVENT *ev, EPOLL_EVENT *ee, int fd)
|
||||
|
||||
if (epx->mask & EVENT_READ) {
|
||||
assert(epx->fe);
|
||||
event_del_read(ev, epx->fe);
|
||||
event_del_read(ev, epx->fe, 0);
|
||||
CLR_READWAIT(epx->fe);
|
||||
}
|
||||
|
||||
if (epx->mask & EVENT_WRITE) {
|
||||
assert(epx->fe);
|
||||
event_del_write(ev, epx->fe);
|
||||
event_del_write(ev, epx->fe, 0);
|
||||
CLR_WRITEWAIT(epx->fe);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ static void read_callback(EVENT *ev, FILE_EVENT *fe)
|
||||
POLLFD *pfd;
|
||||
RING *iter = fe->pfds.succ, *next = iter;
|
||||
|
||||
event_del_read(ev, fe);
|
||||
event_del_read(ev, fe, 0);
|
||||
SET_READABLE(fe);
|
||||
|
||||
// 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;
|
||||
RING *iter = fe->pfds.succ, *next = iter;
|
||||
|
||||
event_del_write(ev, fe);
|
||||
event_del_write(ev, fe, 0);
|
||||
SET_WRITABLE(fe);
|
||||
|
||||
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->r_timeout = -1;
|
||||
#endif
|
||||
event_del_read(ev, pfd->fe);
|
||||
event_del_read(ev, pfd->fe, 0);
|
||||
pfd->fe->fiber_r = NULL;
|
||||
}
|
||||
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->w_timeout = -1;
|
||||
#endif
|
||||
event_del_write(ev, pfd->fe);
|
||||
event_del_write(ev, pfd->fe, 0);
|
||||
pfd->fe->fiber_w = NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user