Chain PreSelect handler The WebClient token
| 1831 | // <param name="errorset"></param> |
| 1832 | // <param name="blocktime"></param> |
| 1833 | void 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 |
nothing calls this directly
no test coverage detected