Use USE_POLL_WAIT conditional compiling in fiber_io.cpp.

This commit is contained in:
zhengshuxin 2024-07-28 18:57:22 +08:00
parent 84095ebbf9
commit 0facec821d
2 changed files with 12 additions and 11 deletions

View File

@ -28,6 +28,7 @@ CFLAGS = -c -g -W \
-O3 \ -O3 \
-DUSE_CLOCK_GETTIME \ -DUSE_CLOCK_GETTIME \
#-DUSE_VALGRIND \ #-DUSE_VALGRIND \
#-DUSE_POLL_WAIT \
#-DDEBUG_READY \ #-DDEBUG_READY \
#-DUSE_INLINE_MEMCPY\ #-DUSE_INLINE_MEMCPY\
#-DUSE_FAST_TIME \ #-DUSE_FAST_TIME \

View File

@ -446,7 +446,7 @@ size_t acl_fiber_sleep(size_t seconds)
/****************************************************************************/ /****************************************************************************/
#ifndef USE_TIMER #ifdef USE_POLL_WAIT
static int timed_wait(socket_t fd, int delay, int oper) static int timed_wait(socket_t fd, int delay, int oper)
{ {
@ -485,7 +485,7 @@ static int timed_wait(socket_t fd, int delay, int oper)
} }
} }
} }
#endif // !USE_TIMER #endif // USE_POLL_WAIT
static void read_callback(EVENT *ev, FILE_EVENT *fe) static void read_callback(EVENT *ev, FILE_EVENT *fe)
{ {
@ -523,7 +523,7 @@ int fiber_wait_read(FILE_EVENT *fe)
return -1; return -1;
} }
#ifndef USE_TIMER #ifdef USE_POLL_WAIT
if ((fe->mask & EVENT_SO_RCVTIMEO) && fe->r_timeout > 0) { if ((fe->mask & EVENT_SO_RCVTIMEO) && fe->r_timeout > 0) {
ret = timed_wait(fe->fd, fe->r_timeout, POLLIN); ret = timed_wait(fe->fd, fe->r_timeout, POLLIN);
if (ret == 0) { if (ret == 0) {
@ -550,7 +550,7 @@ int fiber_wait_read(FILE_EVENT *fe)
WAITER_INC(__thread_fiber->event); WAITER_INC(__thread_fiber->event);
} }
#ifdef USE_TIMER #ifndef USE_POLL_WAIT
if ((fe->mask & EVENT_SO_RCVTIMEO) && fe->r_timeout > 0) { if ((fe->mask & EVENT_SO_RCVTIMEO) && fe->r_timeout > 0) {
fiber_timer_add(curr, fe->r_timeout); fiber_timer_add(curr, fe->r_timeout);
} }
@ -589,7 +589,7 @@ int fiber_wait_read(FILE_EVENT *fe)
acl_fiber_set_error(curr->errnum); acl_fiber_set_error(curr->errnum);
return -1; return -1;
} }
#ifdef USE_TIMER #ifndef USE_POLL_WAIT
else if (curr->flag & FIBER_F_TIMER) { else if (curr->flag & FIBER_F_TIMER) {
// 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.
@ -636,7 +636,7 @@ int fiber_wait_write(FILE_EVENT *fe)
return -1; return -1;
} }
#ifndef USE_TIMER #ifdef USE_POLL_WAIT
if ((fe->mask & EVENT_SO_SNDTIMEO) && fe->w_timeout > 0) { if ((fe->mask & EVENT_SO_SNDTIMEO) && fe->w_timeout > 0) {
ret = timed_wait(fe->fd, fe->w_timeout, POLLOUT); ret = timed_wait(fe->fd, fe->w_timeout, POLLOUT);
if (ret == 0) { if (ret == 0) {
@ -662,7 +662,7 @@ int fiber_wait_write(FILE_EVENT *fe)
WAITER_INC(__thread_fiber->event); WAITER_INC(__thread_fiber->event);
} }
#ifdef USE_TIMER #ifndef USE_POLL_WAIT
if ((fe->mask & EVENT_SO_SNDTIMEO) && fe->w_timeout > 0) { if ((fe->mask & EVENT_SO_SNDTIMEO) && fe->w_timeout > 0) {
fiber_timer_add(curr, fe->w_timeout); fiber_timer_add(curr, fe->w_timeout);
} }
@ -682,7 +682,7 @@ int fiber_wait_write(FILE_EVENT *fe)
acl_fiber_set_error(curr->errnum); acl_fiber_set_error(curr->errnum);
return -1; return -1;
} }
#ifdef USE_TIMER #ifndef USE_POLL_WAIT
else if (curr->flag & FIBER_F_TIMER) { else if (curr->flag & FIBER_F_TIMER) {
curr->flag &= ~FIBER_F_TIMER; curr->flag &= ~FIBER_F_TIMER;
event_del_write(__thread_fiber->event, fe, 1); event_del_write(__thread_fiber->event, fe, 1);