Here's the snippet from the code (it gives the error on the line ret = select(FD_SETSIZE , &rdSet, NULL, NULL, NULL );):
Code: Select all
/************************************************************************
* Function: RunMiniServer
*
* Parameters:
* MiniServerSockArray *miniSock - Socket Array
*
* Description:
* Function runs the miniserver. The MiniServer accepts a
* new request and schedules a thread to handle the new request.
* Checks for socket state and invokes appropriate read and shutdown
* actions for the Miniserver and SSDP sockets
*
* Return: void
************************************************************************/
static void
RunMiniServer( MiniServerSockArray *miniSock )
{
char errorBuffer[ERROR_BUFFER_LEN];
struct sockaddr_in clientAddr;
socklen_t clientLen;
SOCKET connectHnd;
SOCKET miniServSock = miniSock->miniServerSock;
SOCKET miniServStopSock = miniSock->miniServerStopSock;
SOCKET ssdpSock = miniSock->ssdpSock;
#ifdef INCLUDE_CLIENT_APIS
SOCKET ssdpReqSock = miniSock->ssdpReqSock;
#endif
fd_set expSet;
fd_set rdSet;
unsigned int maxMiniSock;
int byteReceived;
char requestBuf[256];
int ret = 0;
maxMiniSock = max( miniServSock, miniServStopSock) ;
maxMiniSock = max( maxMiniSock, (SOCKET)(ssdpSock) );
#ifdef INCLUDE_CLIENT_APIS
maxMiniSock = max( maxMiniSock, (SOCKET)(ssdpReqSock) );
#endif
++maxMiniSock;
gMServState = MSERV_RUNNING;
while( TRUE ) {
FD_ZERO( &rdSet );
FD_ZERO( &expSet );
FD_SET( miniServStopSock, &expSet );
FD_SET( miniServSock, &rdSet );
FD_SET( miniServStopSock, &rdSet );
FD_SET( ssdpSock, &rdSet );
#ifdef INCLUDE_CLIENT_APIS
FD_SET( ssdpReqSock, &rdSet );
#endif
ret = select(FD_SETSIZE , &rdSet, NULL, NULL, NULL );
// ret = select( maxMiniSock, &rdSet, NULL, &expSet, NULL );
if ( ret == -1 ) {
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
UpnpPrintf( UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
"Error %X in select(): %s\n", errno, errorBuffer );
// "Error in select(): %s\n", errorBuffer );
/* Avoid 100% CPU in case of repeated error in select() */
isleep( 1 );
continue;
} else {
if( FD_ISSET( miniServSock, &rdSet ) ) {
clientLen = sizeof( struct sockaddr_in );
connectHnd = accept( miniServSock,
( struct sockaddr * )&clientAddr, &clientLen );
if( connectHnd == -1 ) {
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
UpnpPrintf( UPNP_INFO, MSERV, __FILE__, __LINE__,
"miniserver: Error in accept(): %s\n", errorBuffer );
continue;
}
schedule_request_job( connectHnd, &clientAddr );
}
Any idea what this means? I couldn't find anything similar anywhere...