eventloop_select: introduce error variable
abort process if too many select errors. Prevents error logs from filling log partition. after 90 select errors the log level will be increased for the next calls. after 100 select errors the process aborts (will be restarted by systemd). TODO: inspect sockets to find the bad one.
This commit is contained in:
@@ -41,6 +41,7 @@ static void _signalReadyFdObjects(AQH_OBJECT_LIST2 *ol);
|
||||
|
||||
void AQH_EventLoop_Run(AQH_EVENT_LOOP *eventLoop, int timeoutInMillisecs)
|
||||
{
|
||||
static int selectErrorCount=0;
|
||||
fd_set fdRead;
|
||||
fd_set fdWrite;
|
||||
int highestFd=-1;
|
||||
@@ -61,6 +62,8 @@ void AQH_EventLoop_Run(AQH_EVENT_LOOP *eventLoop, int timeoutInMillisecs)
|
||||
rv=select(highestFd+1, &fdRead, &fdWrite, NULL, &tv);
|
||||
if (rv>0) {
|
||||
/* some fds became active */
|
||||
if (selectErrorCount)
|
||||
selectErrorCount--;
|
||||
_markReadyFdObjects(eventLoop->fdObjectList, &fdRead, AQH_FDOBJECT_FDMODE_READ);
|
||||
_markReadyFdObjects(eventLoop->fdObjectList, &fdWrite, AQH_FDOBJECT_FDMODE_WRITE);
|
||||
_signalReadyFdObjects(eventLoop->fdObjectList);
|
||||
@@ -68,11 +71,24 @@ void AQH_EventLoop_Run(AQH_EVENT_LOOP *eventLoop, int timeoutInMillisecs)
|
||||
else if (rv<0) {
|
||||
if (errno!=EINTR) {
|
||||
/* error */
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on SELECT: %d (%s)", errno, strerror(errno));
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Error on SELECT: %d (%s)", errno, strerror(errno));
|
||||
selectErrorCount++;
|
||||
/* TODO: walk through all sockets to find the bad one */
|
||||
if (selectErrorCount==90) {
|
||||
/* increase log level */
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Increasing log level to INFO");
|
||||
GWEN_Logger_SetLevel(AQH_LOGDOMAIN, GWEN_LoggerLevel_Info);
|
||||
}
|
||||
else if (selectErrorCount==100) {
|
||||
DBG_ERROR(AQH_LOGDOMAIN, "Aborting due to too many SELECT errors, will be restarted by systemd");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* no fd became active (TODO: maybe signal deep idle objects?) */
|
||||
if (selectErrorCount)
|
||||
selectErrorCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user