Remove FAKE_CODE from use
This functionality is not used in tests and parts of it didn't work. Since it is not actively maintained or even used, it is better to remove it.
This commit is contained in:
parent
8a8e1a6650
commit
03951fff11
@ -154,10 +154,6 @@ if(GCOV)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
|
||||
endif()
|
||||
|
||||
if(FAKE_CODE)
|
||||
set(FLAGS "${FLAGS} -DFAKE_CODE" CACHE STRING "Compilation flags" FORCE)
|
||||
endif()
|
||||
|
||||
if(PROFILE)
|
||||
message(STATUS "Profiling executables")
|
||||
set(FLAGS "${FLAGS} -pg " CACHE STRING "Compilation flags" FORCE)
|
||||
|
@ -302,15 +302,6 @@ typedef enum
|
||||
DCB_USAGE_ALL
|
||||
} DCB_USAGE;
|
||||
|
||||
#if defined(FAKE_CODE)
|
||||
extern unsigned char dcb_fake_write_errno[10240];
|
||||
extern __int32_t dcb_fake_write_ev[10240];
|
||||
extern bool fail_next_backend_fd;
|
||||
extern bool fail_next_client_fd;
|
||||
extern int fail_next_accept;
|
||||
extern int fail_accept_errno;
|
||||
#endif /* FAKE_CODE */
|
||||
|
||||
/* A few useful macros */
|
||||
#define DCB_SESSION(x) (x)->session
|
||||
#define DCB_PROTOCOL(x, type) (type *)((x)->protocol)
|
||||
|
@ -561,8 +561,4 @@ typedef enum skygw_chk_t
|
||||
}
|
||||
|
||||
|
||||
#if defined(FAKE_CODE)
|
||||
static bool conn_open[10240];
|
||||
#endif /* FAKE_CODE */
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -93,15 +93,6 @@
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/utils.h>
|
||||
|
||||
#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 /* FAKE_CODE */
|
||||
|
||||
/* The list of all DCBs */
|
||||
static LIST_CONFIG DCBlist =
|
||||
{LIST_TYPE_RECYCLABLE, sizeof(DCB), SPINLOCK_INIT};
|
||||
@ -130,9 +121,6 @@ static int dcb_create_SSL(DCB* dcb, SSL_LISTENER *ssl);
|
||||
static int dcb_read_SSL(DCB *dcb, GWBUF **head);
|
||||
static GWBUF *dcb_basic_read(DCB *dcb, int bytesavailable, int maxbytes, int nreadtotal, int *nsingleread);
|
||||
static GWBUF *dcb_basic_read_SSL(DCB *dcb, int *nsingleread);
|
||||
#if defined(FAKE_CODE)
|
||||
static inline void dcb_write_fake_code(DCB *dcb);
|
||||
#endif
|
||||
static void dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno);
|
||||
static inline void dcb_write_tidy_up(DCB *dcb, bool below_water);
|
||||
static int gw_write(DCB *dcb, GWBUF *writeq, bool *stop_writing);
|
||||
@ -684,9 +672,6 @@ dcb_process_victim_queue(DCB *listofdcb)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(FAKE_CODE)
|
||||
conn_open[dcb->fd] = false;
|
||||
#endif /* FAKE_CODE */
|
||||
dcb->fd = DCBFD_CLOSED;
|
||||
|
||||
MXS_DEBUG("%lu [dcb_process_victim_queue] Closed socket "
|
||||
@ -1387,34 +1372,6 @@ dcb_write(DCB *dcb, GWBUF *queue)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(FAKE_CODE)
|
||||
/**
|
||||
* Fake code for dcb_write
|
||||
* (Should have fuller description)
|
||||
*
|
||||
* @param dcb The DCB of the client
|
||||
*/
|
||||
static inline void
|
||||
dcb_write_fake_code(DCB *dcb)
|
||||
{
|
||||
if (dcb->session != NULL)
|
||||
{
|
||||
if (dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER && fail_next_client_fd)
|
||||
{
|
||||
dcb_fake_write_errno[dcb->fd] = 32;
|
||||
dcb_fake_write_ev[dcb->fd] = 29;
|
||||
fail_next_client_fd = false;
|
||||
}
|
||||
else if (dcb->dcb_role == DCB_ROLE_BACKEND_HANDLER && fail_next_backend_fd)
|
||||
{
|
||||
dcb_fake_write_errno[dcb->fd] = 32;
|
||||
dcb_fake_write_ev[dcb->fd] = 29;
|
||||
fail_next_backend_fd = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* FAKE_CODE */
|
||||
|
||||
/**
|
||||
* Check the parameters for dcb_write
|
||||
*
|
||||
@ -2425,28 +2382,10 @@ gw_write(DCB *dcb, GWBUF *writeq, bool *stop_writing)
|
||||
|
||||
errno = 0;
|
||||
|
||||
#if defined(FAKE_CODE)
|
||||
if (fd > 0 && dcb_fake_write_errno[fd] != 0)
|
||||
{
|
||||
ss_dassert(dcb_fake_write_ev[fd] != 0);
|
||||
written = write(fd, buf, nbytes / 2); /*< leave peer to read missing bytes */
|
||||
|
||||
if (written > 0)
|
||||
{
|
||||
written = -1;
|
||||
errno = dcb_fake_write_errno[fd];
|
||||
}
|
||||
}
|
||||
else if (fd > 0)
|
||||
{
|
||||
written = write(fd, buf, nbytes);
|
||||
}
|
||||
#else
|
||||
if (fd > 0)
|
||||
{
|
||||
written = write(fd, buf, nbytes);
|
||||
}
|
||||
#endif /* FAKE_CODE */
|
||||
|
||||
saved_errno = errno;
|
||||
errno = 0;
|
||||
@ -3093,14 +3032,9 @@ dcb_accept(DCB *listener, GWPROTOCOL *protocol_funcs)
|
||||
if ((c_sock = dcb_accept_one_connection(listener, (struct sockaddr *)&client_conn)) >= 0)
|
||||
{
|
||||
listener->stats.n_accepts++;
|
||||
#if defined(SS_DEBUG)
|
||||
MXS_DEBUG("%lu [gw_MySQLAccept] Accepted fd %d.",
|
||||
pthread_self(),
|
||||
c_sock);
|
||||
#endif /* SS_DEBUG */
|
||||
#if defined(FAKE_CODE)
|
||||
conn_open[c_sock] = true;
|
||||
#endif /* FAKE_CODE */
|
||||
/* set nonblocking */
|
||||
sendbuf = MXS_CLIENT_SO_SNDBUF;
|
||||
|
||||
@ -3233,27 +3167,12 @@ dcb_accept_one_connection(DCB *listener, struct sockaddr *client_conn)
|
||||
socklen_t client_len = sizeof(struct sockaddr_storage);
|
||||
int eno = 0;
|
||||
|
||||
#if defined(FAKE_CODE)
|
||||
if (fail_next_accept > 0)
|
||||
{
|
||||
c_sock = -1;
|
||||
eno = fail_accept_errno;
|
||||
fail_next_accept -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail_accept_errno = 0;
|
||||
#endif /* FAKE_CODE */
|
||||
|
||||
/* new connection from client */
|
||||
c_sock = accept(listener->fd,
|
||||
client_conn,
|
||||
&client_len);
|
||||
eno = errno;
|
||||
errno = 0;
|
||||
#if defined(FAKE_CODE)
|
||||
}
|
||||
#endif /* FAKE_CODE */
|
||||
/* new connection from client */
|
||||
c_sock = accept(listener->fd,
|
||||
client_conn,
|
||||
&client_len);
|
||||
eno = errno;
|
||||
errno = 0;
|
||||
|
||||
if (c_sock == -1)
|
||||
{
|
||||
@ -3371,9 +3290,6 @@ dcb_listen(DCB *listener, const char *config, const char *protocol_name)
|
||||
"attempting to register on an epoll instance.");
|
||||
return -1;
|
||||
}
|
||||
#if defined(FAKE_CODE)
|
||||
conn_open[listener_socket] = true;
|
||||
#endif /* FAKE_CODE */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1310,15 +1310,6 @@ int main(int argc, char **argv)
|
||||
progname = *argv;
|
||||
snprintf(datadir, PATH_MAX, "%s", default_datadir);
|
||||
datadir[PATH_MAX] = '\0';
|
||||
#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);
|
||||
fail_next_backend_fd = false;
|
||||
fail_next_client_fd = false;
|
||||
fail_next_accept = 0;
|
||||
fail_accept_errno = 0;
|
||||
#endif /* FAKE_CODE */
|
||||
file_write_header(stderr);
|
||||
/*<
|
||||
* Register functions which are called at exit except libmysqld-related,
|
||||
|
@ -895,18 +895,6 @@ process_pollq(int thread_id)
|
||||
thread_data[thread_id].event = ev;
|
||||
}
|
||||
|
||||
#if defined(FAKE_CODE)
|
||||
if (dcb_fake_write_ev[dcb->fd] != 0)
|
||||
{
|
||||
MXS_DEBUG("%lu [poll_waitevents] "
|
||||
"Added fake events %d to ev %d.",
|
||||
pthread_self(),
|
||||
dcb_fake_write_ev[dcb->fd],
|
||||
ev);
|
||||
ev |= dcb_fake_write_ev[dcb->fd];
|
||||
dcb_fake_write_ev[dcb->fd] = 0;
|
||||
}
|
||||
#endif /* FAKE_CODE */
|
||||
ss_debug(spinlock_acquire(&dcb->dcb_initlock));
|
||||
ss_dassert(dcb->state != DCB_STATE_ALLOC);
|
||||
/* It isn't obvious that this is impossible */
|
||||
@ -1007,20 +995,6 @@ process_pollq(int thread_id)
|
||||
if (ev & EPOLLERR)
|
||||
{
|
||||
int eno = gw_getsockerrno(dcb->fd);
|
||||
#if defined(FAKE_CODE)
|
||||
if (eno == 0)
|
||||
{
|
||||
eno = dcb_fake_write_errno[dcb->fd];
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
MXS_DEBUG("%lu [poll_waitevents] "
|
||||
"Added fake errno %d. "
|
||||
"%s",
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror_r(eno, errbuf, sizeof(errbuf)));
|
||||
}
|
||||
dcb_fake_write_errno[dcb->fd] = 0;
|
||||
#endif /* FAKE_CODE */
|
||||
if (eno != 0)
|
||||
{
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
|
@ -402,9 +402,6 @@ gw_do_connect_to_backend(char *host, int port, int *fd)
|
||||
MXS_DEBUG("%lu [gw_do_connect_to_backend] Connected to backend server "
|
||||
"%s:%d, fd %d.",
|
||||
pthread_self(), host, port, so);
|
||||
#if defined(FAKE_CODE)
|
||||
conn_open[so] = true;
|
||||
#endif /* FAKE_CODE */
|
||||
|
||||
return_rv:
|
||||
return rv;
|
||||
|
@ -732,51 +732,6 @@ struct subcommand disableoptions[] =
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(FAKE_CODE)
|
||||
|
||||
static void fail_backendfd(void);
|
||||
static void fail_clientfd(void);
|
||||
static void fail_accept(DCB* dcb, char* arg1, char* arg2);
|
||||
/**
|
||||
* * The subcommands of the fail command
|
||||
* */
|
||||
struct subcommand failoptions[] =
|
||||
{
|
||||
{
|
||||
"backendfd",
|
||||
0,
|
||||
fail_backendfd,
|
||||
"Fail backend socket for next operation.",
|
||||
"Fail backend socket for next operation.",
|
||||
{ARG_TYPE_STRING, 0, 0}
|
||||
},
|
||||
{
|
||||
"clientfd",
|
||||
0,
|
||||
fail_clientfd,
|
||||
"Fail client socket for next operation.",
|
||||
"Fail client socket for next operation.",
|
||||
{ARG_TYPE_STRING, 0, 0}
|
||||
},
|
||||
{
|
||||
"accept",
|
||||
2,
|
||||
fail_accept,
|
||||
"Fail to accept next client connection.",
|
||||
"Fail to accept next client connection.",
|
||||
{ARG_TYPE_STRING, ARG_TYPE_STRING, 0}
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
{0, 0, 0}
|
||||
}
|
||||
};
|
||||
#endif /* FAKE_CODE */
|
||||
|
||||
static void telnetdAddUser(DCB *, char *user, char *password);
|
||||
|
||||
static void cmd_AddServer(DCB *dcb, void *a, void *b)
|
||||
@ -1231,9 +1186,6 @@ static struct
|
||||
{ "clear", clearoptions },
|
||||
{ "disable", disableoptions },
|
||||
{ "enable", enableoptions },
|
||||
#if defined(FAKE_CODE)
|
||||
{ "fail", failoptions },
|
||||
#endif /* FAKE_CODE */
|
||||
{ "flush", flushoptions },
|
||||
{ "list", listoptions },
|
||||
{ "reload", reloadoptions },
|
||||
@ -2340,50 +2292,3 @@ disable_account(DCB *dcb, char *user)
|
||||
dcb_printf(dcb, "Failed to disable the Linux user %s: %s\n", user, err);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(FAKE_CODE)
|
||||
static void fail_backendfd(void)
|
||||
{
|
||||
fail_next_backend_fd = true;
|
||||
}
|
||||
|
||||
static void fail_clientfd(void)
|
||||
{
|
||||
fail_next_client_fd = true;
|
||||
}
|
||||
|
||||
static void fail_accept(
|
||||
DCB* dcb,
|
||||
char* arg1,
|
||||
char* arg2)
|
||||
{
|
||||
int failcount = MXS_MIN(atoi(arg2), 100);
|
||||
fail_accept_errno = atoi(arg1);
|
||||
char errbuf[MXS_STRERROR_BUFLEN];
|
||||
|
||||
switch (fail_accept_errno)
|
||||
{
|
||||
case EAGAIN:
|
||||
// case EWOULDBLOCK:
|
||||
case EBADF:
|
||||
case EINTR:
|
||||
case EINVAL:
|
||||
case EMFILE:
|
||||
case ENFILE:
|
||||
case ENOTSOCK:
|
||||
case EOPNOTSUPP:
|
||||
case ENOBUFS:
|
||||
case ENOMEM:
|
||||
case EPROTO:
|
||||
fail_next_accept = failcount;
|
||||
break;
|
||||
|
||||
default:
|
||||
dcb_printf(dcb,
|
||||
"[%d, %s] is not valid errno for accept.\n",
|
||||
fail_accept_errno,
|
||||
strerror_r(fail_accept_errno, errbuf, sizeof(errbuf)));
|
||||
return ;
|
||||
}
|
||||
}
|
||||
#endif /* FAKE_CODE */
|
||||
|
Loading…
x
Reference in New Issue
Block a user