Improved behavior of debug cli API command 'fail accept'. It takes now _two_ arguments, Syntax:
fail accept <errno> <repeat count> Changed fail_next_accept from boolean to decreasing counter.
This commit is contained in:
@ -216,7 +216,7 @@ memset(dcb_fake_write_errno, 0, sizeof(unsigned char)*1024);
|
|||||||
memset(dcb_fake_write_ev, 0, sizeof(__int32_t)*1024);
|
memset(dcb_fake_write_ev, 0, sizeof(__int32_t)*1024);
|
||||||
fail_next_backend_fd = false;
|
fail_next_backend_fd = false;
|
||||||
fail_next_client_fd = false;
|
fail_next_client_fd = false;
|
||||||
fail_next_accept = false;
|
fail_next_accept = 0;
|
||||||
fail_accept_errno = 0;
|
fail_accept_errno = 0;
|
||||||
#endif
|
#endif
|
||||||
l = atexit(skygw_logmanager_exit);
|
l = atexit(skygw_logmanager_exit);
|
||||||
|
|||||||
@ -190,7 +190,7 @@ unsigned char dcb_fake_write_errno[1024];
|
|||||||
__int32_t dcb_fake_write_ev[1024];
|
__int32_t dcb_fake_write_ev[1024];
|
||||||
bool fail_next_backend_fd;
|
bool fail_next_backend_fd;
|
||||||
bool fail_next_client_fd;
|
bool fail_next_client_fd;
|
||||||
bool fail_next_accept;
|
int fail_next_accept;
|
||||||
int fail_accept_errno;
|
int fail_accept_errno;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -921,19 +921,23 @@ int gw_MySQLAccept(DCB *listener)
|
|||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
retry_accept:
|
retry_accept:
|
||||||
// new connection from client
|
|
||||||
c_sock = accept(listener->fd,
|
|
||||||
(struct sockaddr *) &local,
|
|
||||||
&addrlen);
|
|
||||||
|
|
||||||
eno = errno;
|
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
if (fail_next_accept) {
|
if (fail_next_accept > 0)
|
||||||
|
{
|
||||||
c_sock = -1;
|
c_sock = -1;
|
||||||
eno = fail_accept_errno;
|
eno = fail_accept_errno;
|
||||||
i = 10;
|
fail_next_accept -= 1;
|
||||||
fail_next_accept = false;
|
} else {
|
||||||
fail_accept_errno = 0;
|
fail_accept_errno = 0;
|
||||||
|
#endif /* SS_DEBUG */
|
||||||
|
// new connection from client
|
||||||
|
c_sock = accept(listener->fd,
|
||||||
|
(struct sockaddr *) &local,
|
||||||
|
&addrlen);
|
||||||
|
eno = errno;
|
||||||
|
errno = 0;
|
||||||
|
#if defined(SS_DEBUG)
|
||||||
}
|
}
|
||||||
#endif /* SS_DEBUG */
|
#endif /* SS_DEBUG */
|
||||||
|
|
||||||
@ -946,30 +950,11 @@ int gw_MySQLAccept(DCB *listener)
|
|||||||
/* We have processed all incoming connections. */
|
/* We have processed all incoming connections. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (eno == ENFILE)
|
else if (eno == ENFILE || eno == EMFILE)
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Exceeded system's max. number of files limit.
|
* Exceeded system's (ENFILE) or processes
|
||||||
*/
|
* (EMFILE) max. number of files limit.
|
||||||
skygw_log_write_flush(
|
|
||||||
LOGFILE_ERROR,
|
|
||||||
"%lu [gw_MySQLAccept] Error %d, %s.",
|
|
||||||
pthread_self(),
|
|
||||||
eno,
|
|
||||||
strerror(eno));
|
|
||||||
i++;
|
|
||||||
usleep(100*i*i);
|
|
||||||
|
|
||||||
if (i<10) {
|
|
||||||
goto retry_accept;
|
|
||||||
}
|
|
||||||
rc = 1;
|
|
||||||
goto return_rc;
|
|
||||||
}
|
|
||||||
else if (eno == EMFILE)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Exceeded processes max. number of files limit.
|
|
||||||
*/
|
*/
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
|
|||||||
@ -233,7 +233,7 @@ struct subcommand disableoptions[] = {
|
|||||||
|
|
||||||
static void fail_backendfd(void);
|
static void fail_backendfd(void);
|
||||||
static void fail_clientfd(void);
|
static void fail_clientfd(void);
|
||||||
static void fail_accept(DCB* dcb, char* arg1);
|
static void fail_accept(DCB* dcb, char* arg1, char* arg2);
|
||||||
/**
|
/**
|
||||||
* * The subcommands of the fail command
|
* * The subcommands of the fail command
|
||||||
* */
|
* */
|
||||||
@ -254,10 +254,10 @@ struct subcommand failoptions[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"accept",
|
"accept",
|
||||||
1,
|
2,
|
||||||
fail_accept,
|
fail_accept,
|
||||||
"Fail to accept next client connection.",
|
"Fail to accept next client connection.",
|
||||||
{ARG_TYPE_STRING, 0, 0}
|
{ARG_TYPE_STRING, ARG_TYPE_STRING, 0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
NULL,
|
NULL,
|
||||||
@ -775,10 +775,13 @@ static void fail_clientfd(void)
|
|||||||
|
|
||||||
static void fail_accept(
|
static void fail_accept(
|
||||||
DCB* dcb,
|
DCB* dcb,
|
||||||
char* arg1)
|
char* arg1,
|
||||||
|
char* arg2)
|
||||||
{
|
{
|
||||||
|
int failcount = MIN(atoi(arg2), 100);
|
||||||
fail_accept_errno = atoi(arg1);
|
fail_accept_errno = atoi(arg1);
|
||||||
|
|
||||||
|
|
||||||
switch(fail_accept_errno) {
|
switch(fail_accept_errno) {
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
// case EWOULDBLOCK:
|
// case EWOULDBLOCK:
|
||||||
@ -792,7 +795,7 @@ static void fail_accept(
|
|||||||
case ENOBUFS:
|
case ENOBUFS:
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
case EPROTO:
|
case EPROTO:
|
||||||
fail_next_accept = true;
|
fail_next_accept = failcount;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user