Skip to content

Commit

Permalink
Delete some debug codes in fiber module.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengshuxin committed Oct 28, 2024
1 parent 112c6cf commit 1fc4f9a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 85 deletions.
2 changes: 1 addition & 1 deletion lib_acl/src/init/acl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "init.h"

static char *version = "3.6.1-6 20241028-11:08";
static char *version = "3.6.1-6 20241028-13:45";

const char *acl_version(void)
{
Expand Down
1 change: 0 additions & 1 deletion lib_fiber/c/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ CFLAGS = -c -g -W \
-O3 \
-DUSE_CLOCK_GETTIME \
#-DUSE_VALGRIND \
#-DUSE_POLL_WAIT \
#-DDEBUG_READY \
#-DUSE_INLINE_MEMCPY\
#-DUSE_FAST_TIME \
Expand Down
85 changes: 2 additions & 83 deletions lib_fiber/c/src/fiber_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,47 +444,6 @@ size_t acl_fiber_sleep(size_t seconds)

/****************************************************************************/

#ifdef USE_POLL_WAIT

static int timed_wait(socket_t fd, int delay, int oper)
{
struct pollfd fds;
fds.events = oper;
fds.fd = fd;

for (;;) {
switch (acl_fiber_poll(&fds, 1, delay)) {
# ifdef SYS_WIN
case SOCKET_ERROR:
# else
case -1:
# endif
if (acl_fiber_last_error() == FIBER_EINTR) {
continue;
}
break;
case 0:
return 0;
default:
if (oper == POLLIN) {
if ((fds.revents & POLLIN)) {
return 1;
}
} else if (oper == POLLOUT) {
if ((fds.revents & POLLOUT)) {
return 1;
}
}

if (fds.revents & (POLLHUP | POLLERR | POLLNVAL)) {
return -1;
}
return -1;
}
}
}
#endif // USE_POLL_WAIT

static void read_callback(EVENT *ev, FILE_EVENT *fe)
{
CLR_READWAIT(fe);
Expand Down Expand Up @@ -521,19 +480,6 @@ int fiber_wait_read(FILE_EVENT *fe)
return -1;
}

#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) {
acl_fiber_set_errno(curr, FIBER_EAGAIN);
acl_fiber_set_error(FIBER_EAGAIN);
return -1;
}

return ret == 1 ? 0 : -1;
}
#endif

// When return 0 just let it go continue
ret = event_add_read(__thread_fiber->event, fe, read_callback);
if (ret <= 0) {
Expand All @@ -548,19 +494,15 @@ int fiber_wait_read(FILE_EVENT *fe)
WAITER_INC(__thread_fiber->event);
}

#ifndef USE_POLL_WAIT
if ((fe->mask & EVENT_SO_RCVTIMEO) && fe->r_timeout > 0) {
fiber_timer_add(curr, fe->r_timeout);
}
#endif

acl_fiber_switch();

#ifndef USE_POLL_WAIT
if ((fe->mask & EVENT_SO_RCVTIMEO) && fe->r_timeout > 0) {
fiber_timer_del(curr);
}
#endif

fe->fiber_r->wstatus &= ~FIBER_WAIT_READ;
fe->fiber_r = NULL;
Expand All @@ -580,9 +522,7 @@ int fiber_wait_read(FILE_EVENT *fe)
event_del_read(__thread_fiber->event, fe, 1);
acl_fiber_set_error(curr->errnum);
return -1;
}
#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.
// Clear FIBER_F_TIMER flag been set in wakeup_timers.
curr->flag &= ~FIBER_F_TIMER;
Expand All @@ -592,7 +532,6 @@ int fiber_wait_read(FILE_EVENT *fe)
acl_fiber_set_error(FIBER_EAGAIN);
return -1;
}
#endif
// else: the IO read event should have been removed in read_callback.

return ret;
Expand Down Expand Up @@ -626,19 +565,6 @@ int fiber_wait_write(FILE_EVENT *fe)
return -1;
}

#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) {
acl_fiber_set_errno(curr, FIBER_EAGAIN);
acl_fiber_set_error(FIBER_EAGAIN);
return -1;
}

return ret == 1 ? 0 : -1;
}
#endif

ret = event_add_write(__thread_fiber->event, fe, write_callback);
if (ret <= 0) {
return ret;
Expand All @@ -652,19 +578,15 @@ int fiber_wait_write(FILE_EVENT *fe)
WAITER_INC(__thread_fiber->event);
}

#ifndef USE_POLL_WAIT
if ((fe->mask & EVENT_SO_SNDTIMEO) && fe->w_timeout > 0) {
fiber_timer_add(curr, fe->w_timeout);
}
#endif

acl_fiber_switch();

#ifndef USE_POLL_WAIT
if ((fe->mask & EVENT_SO_SNDTIMEO) && fe->w_timeout > 0) {
fiber_timer_del(curr);
}
#endif

fe->fiber_w->wstatus &= ~FIBER_WAIT_WRITE;
fe->fiber_w = NULL;
Expand All @@ -677,17 +599,14 @@ int fiber_wait_write(FILE_EVENT *fe)
event_del_write(__thread_fiber->event, fe, 1);
acl_fiber_set_error(curr->errnum);
return -1;
}
#ifndef USE_POLL_WAIT
else if (curr->flag & FIBER_F_TIMER) {
} else if (curr->flag & FIBER_F_TIMER) {
curr->flag &= ~FIBER_F_TIMER;
event_del_write(__thread_fiber->event, fe, 0);

acl_fiber_set_errno(curr, FIBER_EAGAIN);
acl_fiber_set_error(FIBER_EAGAIN);
return -1;
}
#endif

return ret;
}
Expand Down
1 change: 1 addition & 0 deletions lib_fiber/c/src/hook/fiber_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static int wait_write(FILE_EVENT *fe)

if (fiber_wait_write(fe) < 0) {
// Bugfix: Don't free fe here, or crash will happen!.
// --zsx, 2024.10.25.
// fiber_file_free(fe);
return -1;
}
Expand Down

0 comments on commit 1fc4f9a

Please sign in to comment.