If accept fails due too many open fails, now ENFILE (system level file limit exceeded) and EMFILE (process limit) are separated and logged diffenretly.
This commit is contained in:
@ -844,26 +844,73 @@ int gw_MySQLAccept(DCB *listener)
|
|||||||
MySQLProtocol *protocol;
|
MySQLProtocol *protocol;
|
||||||
int sendbuf = GW_BACKEND_SO_SNDBUF;
|
int sendbuf = GW_BACKEND_SO_SNDBUF;
|
||||||
socklen_t optlen = sizeof(sendbuf);
|
socklen_t optlen = sizeof(sendbuf);
|
||||||
|
int eno = 0;
|
||||||
|
static int i;
|
||||||
|
|
||||||
|
retry_accept:
|
||||||
// new connection from client
|
// new connection from client
|
||||||
c_sock = accept(listener->fd,
|
c_sock = accept(listener->fd,
|
||||||
(struct sockaddr *) &local,
|
(struct sockaddr *) &local,
|
||||||
&addrlen);
|
&addrlen);
|
||||||
|
|
||||||
|
eno = errno;
|
||||||
|
|
||||||
if (c_sock == -1) {
|
if (c_sock == -1) {
|
||||||
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
|
|
||||||
/* We have processed all incoming connections. */
|
if (eno == EAGAIN ||
|
||||||
break;
|
eno == EWOULDBLOCK)
|
||||||
} else {
|
{
|
||||||
fprintf(stderr,
|
/* We have processed all incoming connections. */
|
||||||
"Accept error for %i, Err: %i, %s\n",
|
break;
|
||||||
listener->fd,
|
}
|
||||||
errno,
|
else if (eno == ENFILE)
|
||||||
strerror(errno));
|
{
|
||||||
// what else to do?
|
|
||||||
return 1;
|
/**
|
||||||
}
|
* Exceeded system's max. number of files limit.
|
||||||
}
|
*/
|
||||||
|
skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"%lu [gw_MySQLAccept] Error %d, %s.",
|
||||||
|
pthread_self(),
|
||||||
|
eno,
|
||||||
|
strerror(eno));
|
||||||
|
usleep(100*i*i++);
|
||||||
|
goto retry_accept;
|
||||||
|
}
|
||||||
|
else if (eno == EMFILE)
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exceeded processes max. number of files limit.
|
||||||
|
*/
|
||||||
|
skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"%lu [gw_MySQLAccept] Error %d, %s.",
|
||||||
|
pthread_self(),
|
||||||
|
eno,
|
||||||
|
strerror(eno));
|
||||||
|
usleep(100*i*i++);
|
||||||
|
goto retry_accept;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Other error.
|
||||||
|
*/
|
||||||
|
skygw_log_write_flush(
|
||||||
|
LOGFILE_ERROR,
|
||||||
|
"%lu [gw_MySQLAccept] Error %d, %s.",
|
||||||
|
pthread_self(),
|
||||||
|
eno,
|
||||||
|
strerror(eno));
|
||||||
|
ss_dassert(false);
|
||||||
|
break;
|
||||||
|
} /* if (eno == ..) */
|
||||||
|
} /* if (c_sock == -1) */
|
||||||
|
/* reset counter */
|
||||||
|
i = 0;
|
||||||
|
|
||||||
listener->stats.n_accepts++;
|
listener->stats.n_accepts++;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user