! \fn ILibCreateWebClient(int PoolSize,void *Chain) \brief Constructor to create a new ILibWebClient \param PoolSize The max number of ILibAsyncSockets to have in the pool \param Chain The chain to add this module to. (Chain must not be running) \returns An ILibWebClient */
| 1992 | \returns An ILibWebClient |
| 1993 | */ |
| 1994 | ILibWebClient_RequestManager ILibCreateWebClient(int PoolSize, void *Chain) |
| 1995 | { |
| 1996 | int i; |
| 1997 | struct ILibWebClientManager *RetVal; |
| 1998 | |
| 1999 | if (Chain == NULL) return NULL; |
| 2000 | |
| 2001 | if ((RetVal = (struct ILibWebClientManager*)malloc(sizeof(struct ILibWebClientManager))) == NULL) ILIBCRITICALEXIT(254); |
| 2002 | memset(RetVal, 0, sizeof(struct ILibWebClientManager)); |
| 2003 | RetVal->MaxConnectionsToSameServer = 1; |
| 2004 | |
| 2005 | RetVal->Destroy = &ILibDestroyWebClient; |
| 2006 | RetVal->PreSelect = &ILibWebClient_PreProcess; |
| 2007 | //RetVal->PostSelect = &ILibWebClient_PreProcess; |
| 2008 | |
| 2009 | RetVal->socksLength = PoolSize; |
| 2010 | RetVal->socks = (void**)malloc(PoolSize * sizeof(void*)); |
| 2011 | if (RetVal->socks == NULL) ILIBCRITICALEXIT(254); |
| 2012 | sem_init(&(RetVal->QLock), 0, 1); |
| 2013 | RetVal->Chain = Chain; |
| 2014 | |
| 2015 | RetVal->backlogQueue = ILibQueue_Create(); |
| 2016 | RetVal->DataTable = ILibInitHashTree(); |
| 2017 | RetVal->idleTable = ILibInitHashTree(); |
| 2018 | |
| 2019 | ILibAddToChain(Chain,RetVal); |
| 2020 | RetVal->timer = ILibGetBaseTimer(Chain); //ILibCreateLifeTime(Chain); |
| 2021 | |
| 2022 | #ifndef MICROSTACK_NOTLS |
| 2023 | RetVal->ssl_ctx = NULL; |
| 2024 | #endif |
| 2025 | |
| 2026 | // Create our pool of sockets |
| 2027 | for(i = 0; i < PoolSize; ++i) |
| 2028 | { |
| 2029 | RetVal->socks[i] = ILibCreateAsyncSocketModule( |
| 2030 | Chain, |
| 2031 | INITIAL_BUFFER_SIZE, |
| 2032 | &ILibWebClient_OnData, |
| 2033 | &ILibWebClient_OnConnect, |
| 2034 | &ILibWebClient_OnDisconnectSink, |
| 2035 | &ILibWebClient_OnSendOKSink); |
| 2036 | // |
| 2037 | // We want to know about any buffer reallocations, because we may need to fix some things |
| 2038 | // |
| 2039 | ILibAsyncSocket_SetReAllocateNotificationCallback(RetVal->socks[i], &ILibWebClient_OnBufferReAllocate); |
| 2040 | } |
| 2041 | return((void*)RetVal); |
| 2042 | } |
| 2043 | |
| 2044 | void ILibWebClient_SetMaxConcurrentSessionsToServer(ILibWebClient_RequestManager WebClient, int maxConnections) |
| 2045 | { |
nothing calls this directly
no test coverage detected