MCPcopy Create free account
hub / github.com/HumbleNet/HumbleNet / ILibWebClient_PreProcess

Function ILibWebClient_PreProcess

3rdparty/webrtc/Microstack/ILibWebClient.c:1833–1887  ·  view source on GitHub ↗

Chain PreSelect handler The WebClient token

Source from the content-addressed store, hash-verified

1831// <param name="errorset"></param>
1832// <param name="blocktime"></param>
1833void ILibWebClient_PreProcess(void* WebClientModule, fd_set *readset, fd_set *writeset, fd_set *errorset, int* blocktime)
1834{
1835 struct ILibWebClientManager *wcm = (struct ILibWebClientManager*)WebClientModule;
1836 struct ILibWebClientDataObject *wcdo;
1837 int xOK = 0;
1838 int i;
1839
1840 UNREFERENCED_PARAMETER( readset );
1841 UNREFERENCED_PARAMETER( writeset );
1842 UNREFERENCED_PARAMETER( errorset );
1843 UNREFERENCED_PARAMETER( blocktime );
1844
1845 //
1846 // Try and satisfy as many things as we can. If we have resources
1847 // grab a socket and go
1848 //
1849 SEM_TRACK(WebClient_TrackLock("ILibWebClient_PreProcess",1,wcm);)
1850 sem_wait(&(wcm->QLock));
1851 while (xOK == 0 && ILibQueue_IsEmpty(wcm->backlogQueue) == 0)
1852 {
1853 xOK = 1;
1854 for(i=0;i<wcm->socksLength;++i)
1855 {
1856 if (ILibAsyncSocket_IsFree(wcm->socks[i]) != 0)
1857 {
1858 xOK = 0;
1859 wcdo = (struct ILibWebClientDataObject *)ILibQueue_DeQueue(wcm->backlogQueue);
1860 if (wcdo != NULL)
1861 {
1862 wcdo->Closing = 0;
1863 wcdo->PendingConnectionIndex = i;
1864
1865 // TODO: This function call can be locking!!
1866 ILibAsyncSocket_ConnectTo(
1867 wcm->socks[i],
1868 NULL,
1869 (struct sockaddr*)&wcdo->remote,
1870 NULL,
1871 wcdo);
1872
1873 // We need SOCKET information to timeout connect for Network Discovery purpose.
1874 wcdo->SOCK = wcm->socks[i];
1875
1876 // Addition for TLS purpose
1877 #ifndef MICROSTACK_NOTLS
1878 if (wcm->ssl_ctx != NULL) ILibAsyncSocket_SetSSLContext(wcdo->SOCK, wcm->ssl_ctx, 0);
1879 #endif
1880 }
1881 }
1882 if (ILibQueue_IsEmpty(wcm->backlogQueue) != 0) break;
1883 }
1884 }
1885 SEM_TRACK(WebClient_TrackUnLock("ILibWebClient_PreProcess", 2, wcm);)
1886 sem_post(&(wcm->QLock));
1887}
1888
1889//
1890// Internal method dispatched by either ILibWebServer or ILibWebClient, to recheck the headers

Callers

nothing calls this directly

Calls 7

WebClient_TrackLockFunction · 0.85
ILibQueue_IsEmptyFunction · 0.85
ILibAsyncSocket_IsFreeFunction · 0.85
ILibQueue_DeQueueFunction · 0.85
WebClient_TrackUnLockFunction · 0.85

Tested by

no test coverage detected