/** @memo @doc @return error code */ SOAP_INT32 SOAP_ActionExecute ( SOAPAction* action ) { SOAP_BOOL done = 0; RTP_FD_SET readList; RTP_FD_SET writeList; RTP_FD_SET errList; SOAP_INT32 timeoutMsec; while (!done) { rtp_fd_zero(&readList); rtp_fd_zero(&writeList); rtp_fd_zero(&errList); timeoutMsec = SOAP_ActionAddToSelectList(action, &readList, &writeList, &errList); rtp_net_select(&readList, &writeList, &errList, timeoutMsec); done = SOAP_ActionProcessState(action, &readList, &writeList, &errList); } if (action->state == SOAP_ACTION_RESPONSE_READ) { return (0); } return (-1); }
/*---------------------------------------------------------------------------*/ int HTTP_ClientSessionSelect ( HTTPClientSession** writeList, HTTP_INT16* writeNum, HTTPClientSession** readList, HTTP_INT16* readNum, HTTPClientSession** errList, HTTP_INT16* errNum, HTTP_INT32 timeoutMsec ) { RTP_FD_SET writeSet; RTP_FD_SET readSet; RTP_FD_SET errSet; int result = 0; int total = 0; total += _HTTP_ClientSessionListToFdset (&writeSet, writeList, *writeNum); total += _HTTP_ClientSessionListToFdset (&readSet, readList, *readNum); total += _HTTP_ClientSessionListToFdset (&errSet, errList, *errNum); if (total > 0) { result = rtp_net_select(&readSet, &writeSet, &errSet, timeoutMsec); _HTTP_FdsetToClientSessionList (writeList, writeNum, &writeSet); _HTTP_FdsetToClientSessionList (readList, readNum, &readSet); _HTTP_FdsetToClientSessionList (errList, errNum, &errSet); } return (result); }
int RTIP_SOCKETS_Driver::Select( int nfds, SOCK_fd_set* readfds, SOCK_fd_set* writefds, SOCK_fd_set* exceptfds, const SOCK_timeval* timeout ) { NATIVE_PROFILE_PAL_NETWORK(); int ret; ret = rtp_net_select (( RTP_FD_SET *) readfds, (RTP_FD_SET *) writefds, (RTP_FD_SET *) exceptfds, (struct timeval*) timeout); if(ret == SOCK_SOCKET_ERROR) { DEBUG_HANDLE_SOCKET_ERROR("Select failed", FALSE); } return ret; }
/*----------------------------------------------------------------------------* UPnP_ProcessState *----------------------------------------------------------------------------*/ int _UPnP_ProcessState ( UPnPRuntime* rt, /** pointer to \Ref{UPnPRuntime} struct */ UPNP_INT32 msecTimeout /** time in miliseconds for which the function blocks */ ) { RTP_FD_SET readList; RTP_FD_SET writeList; RTP_FD_SET errList; RTP_INT32 timeout; RTP_UINT32 currentTimeSec; /* reset the select lists */ rtp_fd_zero(&readList); rtp_fd_zero(&writeList); rtp_fd_zero(&errList); currentTimeSec = rtp_get_system_sec(); /* --- DEVICE Announcements ------------------------------ */ if (rt->deviceRuntime) { timeout = rt->deviceRuntime->nextAnnounceTimeSec - currentTimeSec; if (timeout < 0) { timeout = 0; } } else { timeout = msecTimeout; } /* --- SSDP ---------------------------------------------- */ timeout = _UPnP_UpdateTimeout( SSDP_ServerAddToSelectList ( &rt->ssdpContext, &readList, &writeList, &errList ), timeout ); /* --- HTTP Server --------------------------------------- */ rtp_fd_set(&readList, HTTP_ServerGetSocket(&rt->httpServer)); /* --- CONTROL POINT-------------------------------------- */ if (rt->controlPoint) { UPNP_RUNTIME_EXIT_CRITICAL(rt); timeout = _UPnP_UpdateTimeout( rtp_net_sm_add_to_select_list ( &rt->controlPoint->requestManager, &readList, &writeList, &errList ), timeout ); } else { UPNP_RUNTIME_EXIT_CRITICAL(rt); } rtp_net_select(&readList, &writeList, &errList, timeout); UPNP_RUNTIME_ENTER_CRITICAL(rt); /* --- SSDP ---------------------------------------------- */ SSDP_ServerProcessState ( &rt->ssdpContext, &readList, &writeList, &errList ); /* --- HTTP Server --------------------------------------- */ if (rtp_fd_isset(&readList, HTTP_ServerGetSocket(&rt->httpServer))) { UPNP_RUNTIME_EXIT_CRITICAL(rt); HTTP_ServerProcessOneRequest(&rt->httpServer, 0); UPNP_RUNTIME_ENTER_CRITICAL(rt); } /* --- CONTROL POINT-------------------------------------- */ if (rt->controlPoint) { UPNP_RUNTIME_EXIT_CRITICAL(rt); rtp_net_sm_process_state ( &rt->controlPoint->requestManager, &readList, &writeList, &errList ); UPNP_RUNTIME_ENTER_CRITICAL(rt); } /* --- DEVICE Announcements ------------------------------ */ if (rt->deviceRuntime) { currentTimeSec = rtp_get_system_sec(); if ((long)(currentTimeSec - rt->deviceRuntime->nextAnnounceTimeSec) >= 0) { rt->deviceRuntime->nextAnnounceTimeSec = currentTimeSec + rt->deviceRuntime->announceFrequencySec; rt->deviceRuntime->announceAll(rt->deviceRuntime); } } return (0); }