From 0facec821d153405968c70d1f4553fbce86c9f2f Mon Sep 17 00:00:00 2001 From: zhengshuxin Date: Sun, 28 Jul 2024 18:57:22 +0800 Subject: [PATCH] Use USE_POLL_WAIT conditional compiling in fiber_io.cpp. --- lib_fiber/c/Makefile | 1 + lib_fiber/c/src/fiber_io.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib_fiber/c/Makefile b/lib_fiber/c/Makefile index b3d9af953..d7addf4aa 100644 --- a/lib_fiber/c/Makefile +++ b/lib_fiber/c/Makefile @@ -28,6 +28,7 @@ CFLAGS = -c -g -W \ -O3 \ -DUSE_CLOCK_GETTIME \ #-DUSE_VALGRIND \ +#-DUSE_POLL_WAIT \ #-DDEBUG_READY \ #-DUSE_INLINE_MEMCPY\ #-DUSE_FAST_TIME \ diff --git a/lib_fiber/c/src/fiber_io.c b/lib_fiber/c/src/fiber_io.c index 62060cfa9..f54e78141 100644 --- a/lib_fiber/c/src/fiber_io.c +++ b/lib_fiber/c/src/fiber_io.c @@ -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) { @@ -464,7 +464,7 @@ static int timed_wait(socket_t fd, int delay, int oper) if (acl_fiber_last_error() == FIBER_EINTR) { continue; } - break; + break; case 0: return 0; default: @@ -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) { @@ -523,7 +523,7 @@ int fiber_wait_read(FILE_EVENT *fe) return -1; } -#ifndef USE_TIMER +#ifdef USE_POLL_WAIT if ((fe->mask & EVENT_SO_RCVTIMEO) && fe->r_timeout > 0) { ret = timed_wait(fe->fd, fe->r_timeout, POLLIN); if (ret == 0) { @@ -550,7 +550,7 @@ int fiber_wait_read(FILE_EVENT *fe) WAITER_INC(__thread_fiber->event); } -#ifdef USE_TIMER +#ifndef USE_POLL_WAIT if ((fe->mask & EVENT_SO_RCVTIMEO) && fe->r_timeout > 0) { fiber_timer_add(curr, fe->r_timeout); } @@ -589,8 +589,8 @@ int fiber_wait_read(FILE_EVENT *fe) acl_fiber_set_error(curr->errnum); return -1; } -#ifdef USE_TIMER - else if (curr->flag & FIBER_F_TIMER) { +#ifndef USE_POLL_WAIT + else if (curr->flag & FIBER_F_TIMER) { // If the IO reading timeout set in setsockopt. // Clear FIBER_F_TIMER flag been set in wakeup_timers. curr->flag &= ~FIBER_F_TIMER; @@ -636,7 +636,7 @@ int fiber_wait_write(FILE_EVENT *fe) return -1; } -#ifndef USE_TIMER +#ifdef USE_POLL_WAIT if ((fe->mask & EVENT_SO_SNDTIMEO) && fe->w_timeout > 0) { ret = timed_wait(fe->fd, fe->w_timeout, POLLOUT); if (ret == 0) { @@ -662,7 +662,7 @@ int fiber_wait_write(FILE_EVENT *fe) WAITER_INC(__thread_fiber->event); } -#ifdef USE_TIMER +#ifndef USE_POLL_WAIT if ((fe->mask & EVENT_SO_SNDTIMEO) && fe->w_timeout > 0) { fiber_timer_add(curr, fe->w_timeout); } @@ -682,8 +682,8 @@ int fiber_wait_write(FILE_EVENT *fe) acl_fiber_set_error(curr->errnum); return -1; } -#ifdef USE_TIMER - else if (curr->flag & FIBER_F_TIMER) { +#ifndef USE_POLL_WAIT + else if (curr->flag & FIBER_F_TIMER) { curr->flag &= ~FIBER_F_TIMER; event_del_write(__thread_fiber->event, fe, 1);