Put errors ganerating code behind FAKE_CODE macro, which is not defined by default in any build.

This commit is contained in:
VilhoRaatikka 2014-11-10 15:22:08 +02:00
parent 7f7cb0a982
commit 9a5168c3e8
6 changed files with 22 additions and 25 deletions

View File

@ -862,7 +862,7 @@ int below_water;
while (queue != NULL)
{
int qlen;
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
if (dcb->dcb_role == DCB_ROLE_REQUEST_HANDLER &&
dcb->session != NULL)
{
@ -878,7 +878,7 @@ int below_water;
fail_next_backend_fd = false;
}
}
#endif /* SS_DEBUG */
#endif /* FAKE_CODE */
qlen = GWBUF_LENGTH(queue);
GW_NOINTR_CALL(
w = gw_write(
@ -1684,7 +1684,7 @@ int gw_write(
size_t nbytes)
{
int w;
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
if (dcb_fake_write_errno[fd] != 0) {
ss_dassert(dcb_fake_write_ev[fd] != 0);
w = write(fd, buf, nbytes/2); /*< leave peer to read missing bytes */
@ -1698,7 +1698,7 @@ int gw_write(
}
#else
w = write(fd, buf, nbytes);
#endif /* SS_DEBUG && SS_TEST */
#endif /* FAKE_CODE */
#if defined(SS_DEBUG_MYSQL)
{

View File

@ -1025,7 +1025,7 @@ int main(int argc, char **argv)
progname = *argv;
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
memset(conn_open, 0, sizeof(bool)*10240);
memset(dcb_fake_write_errno, 0, sizeof(unsigned char)*10240);
memset(dcb_fake_write_ev, 0, sizeof(__int32_t)*10240);
@ -1033,7 +1033,7 @@ int main(int argc, char **argv)
fail_next_client_fd = false;
fail_next_accept = 0;
fail_accept_errno = 0;
#endif
#endif /* FAKE_CODE */
file_write_header(stderr);
/*<
* Register functions which are called at exit except libmysqld-related,

View File

@ -625,7 +625,7 @@ uint32_t ev;
thread_data[thread_id].event = ev;
}
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
if (dcb_fake_write_ev[dcb->fd] != 0) {
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
@ -637,7 +637,7 @@ uint32_t ev;
ev |= dcb_fake_write_ev[dcb->fd];
dcb_fake_write_ev[dcb->fd] = 0;
}
#endif
#endif /* FAKE_CODE */
ss_debug(spinlock_acquire(&dcb->dcb_initlock);)
ss_dassert(dcb->state != DCB_STATE_ALLOC);
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
@ -735,7 +735,7 @@ uint32_t ev;
if (ev & EPOLLERR)
{
int eno = gw_getsockerrno(dcb->fd);
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
if (eno == 0) {
eno = dcb_fake_write_errno[dcb->fd];
LOGIF(LD, (skygw_log_write(
@ -748,7 +748,7 @@ uint32_t ev;
strerror(eno))));
}
dcb_fake_write_errno[dcb->fd] = 0;
#endif
#endif /* FAKE_CODE */
if (eno != 0) {
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,

View File

@ -252,14 +252,14 @@ typedef struct dcb {
#endif
} DCB;
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
unsigned char dcb_fake_write_errno[10240];
__int32_t dcb_fake_write_ev[10240];
bool fail_next_backend_fd;
bool fail_next_client_fd;
int fail_next_accept;
int fail_accept_errno;
#endif
#endif /* FAKE_CODE */
/* A few useful macros */
#define DCB_SESSION(x) (x)->session

View File

@ -836,9 +836,6 @@ int gw_read_client_event(
}
else
{
GWBUF* errbuf;
bool succp;
modutil_send_mysql_err_packet(dcb,
1,
0,
@ -1108,7 +1105,7 @@ int gw_MySQLAccept(DCB *listener)
retry_accept:
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
if (fail_next_accept > 0)
{
c_sock = -1;
@ -1116,16 +1113,16 @@ int gw_MySQLAccept(DCB *listener)
fail_next_accept -= 1;
} else {
fail_accept_errno = 0;
#endif /* SS_DEBUG */
#endif /* FAKE_CODE */
// new connection from client
c_sock = accept(listener->fd,
(struct sockaddr *) &client_conn,
&client_len);
eno = errno;
errno = 0;
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
}
#endif /* SS_DEBUG */
#endif /* FAKE_CODE */
if (c_sock == -1) {

View File

@ -414,7 +414,7 @@ struct subcommand disableoptions[] = {
}
};
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
static void fail_backendfd(void);
static void fail_clientfd(void);
@ -456,7 +456,7 @@ struct subcommand failoptions[] = {
{0, 0, 0}
}
};
#endif /* SS_DEBUG */
#endif /* FAKE_CODE */
static void telnetdAddUser(DCB *, char *, char *);
/**
@ -502,9 +502,9 @@ static struct {
{ "clear", clearoptions },
{ "disable", disableoptions },
{ "enable", enableoptions },
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
{ "fail", failoptions },
#endif
#endif /* FAKE_CODE */
{ "list", listoptions },
{ "reload", reloadoptions },
{ "remove", removeoptions },
@ -1113,7 +1113,7 @@ static void disable_log_action(DCB *dcb, char *arg1) {
skygw_log_disable(type);
}
#if defined(SS_DEBUG)
#if defined(FAKE_CODE)
static void fail_backendfd(void)
{
fail_next_backend_fd = true;
@ -1157,4 +1157,4 @@ static void fail_accept(
return ;
}
}
#endif
#endif /* FAKE_CODE */