diff --git a/server/core/poll.c b/server/core/poll.c index 35016ca33..2a1067252 100644 --- a/server/core/poll.c +++ b/server/core/poll.c @@ -244,7 +244,21 @@ poll_waitevents(void *arg) __uint32_t ev = events[i].events; CHK_DCB(dcb); - + +#if defined(SS_DEBUG) + if (dcb_fake_write_ev[dcb->fd] != 0) { + skygw_log_write( + LOGFILE_TRACE, + "%lu %d [poll_waitevents] " + "Added fake events %d to ev %d.", + pthread_self(), + thread_id, + dcb_fake_write_ev[dcb->fd], + ev); + ev |= dcb_fake_write_ev[dcb->fd]; + dcb_fake_write_ev[dcb->fd] = 0; + } +#endif ss_debug(spinlock_acquire(&dcb->dcb_initlock);) ss_dassert(dcb->state != DCB_STATE_ALLOC); ss_dassert(dcb->state != DCB_STATE_DISCONNECTED); @@ -261,8 +275,33 @@ poll_waitevents(void *arg) if (ev & EPOLLERR) { - atomic_add(&pollStats.n_error, 1); - dcb->func.error(dcb); + int eno = gw_getsockerrno(dcb->fd); +#if defined(SS_DEBUG) + if (eno == 0) { + eno = dcb_fake_write_errno[dcb->fd]; + skygw_log_write( + LOGFILE_TRACE, + "%lu %d [poll_waitevents] " + "Added fake errno %d. %s", + pthread_self(), + thread_id, + eno, + strerror(eno)); + } + dcb_fake_write_errno[dcb->fd] = 0; +#endif + if (eno != 0) { + skygw_log_write( + LOGFILE_TRACE, + "%lu %d [poll_waitevents] " + "EPOLLERR due %d, %s.", + pthread_self(), + thread_id, + eno, + strerror(eno)); + } + atomic_add(&pollStats.n_error, 1); + dcb->func.error(dcb); if (DCB_ISZOMBIE(dcb)) { continue; } diff --git a/server/modules/routing/debugcmd.c b/server/modules/routing/debugcmd.c index 44b841ec1..c06c24e3f 100644 --- a/server/modules/routing/debugcmd.c +++ b/server/modules/routing/debugcmd.c @@ -206,6 +206,8 @@ struct subcommand disableoptions[] = { {0, 0, 0} } }; +#if defined(SS_DEBUG) + static void fail_backendfd(void); static void fail_clientfd(void); @@ -235,7 +237,7 @@ struct subcommand failoptions[] = { {0, 0, 0} } }; - +#endif /* SS_DEBUG */ static void telnetdAddUser(DCB *, char *, char *); /** @@ -284,7 +286,9 @@ static struct { { "reload", reloadoptions }, { "enable", enableoptions }, { "disable", disableoptions }, +#if defined(SS_DEBUG) { "fail", failoptions }, +#endif { NULL, NULL } }; @@ -728,6 +732,7 @@ static void disable_log_action(DCB *dcb, char *arg1) { skygw_log_disable(type); } +#if defined(SS_DEBUG) static void fail_backendfd(void) { fail_next_backend_fd = TRUE; @@ -737,3 +742,4 @@ static void fail_clientfd(void) { fail_next_client_fd = TRUE; } +#endif