/* The last #include file should be: */
#include "memdebug.h"
-#define CONNECTION_HASH_SIZE 97
-
static void free_bundle_hash_entry(void *freethis)
{
struct connectbundle *b = (struct connectbundle *) freethis;
Curl_bundle_destroy(b);
}
-struct conncache *Curl_conncache_init(void)
+struct conncache *Curl_conncache_init(int size)
{
struct conncache *connc;
if(!connc)
return NULL;
- connc->hash = Curl_hash_alloc(CONNECTION_HASH_SIZE, Curl_hash_str,
+ connc->hash = Curl_hash_alloc(size, Curl_hash_str,
Curl_str_key_compare, free_bundle_hash_entry);
if(!connc->hash) {
size_t num_connections;
};
-struct conncache *Curl_conncache_init(void);
+struct conncache *Curl_conncache_init(int size);
void Curl_conncache_destroy(struct conncache *connc);
#include "non-ascii.h"
#include "warnless.h"
#include "conncache.h"
+#include "multiif.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
if(data->multi_easy)
multi = data->multi_easy;
else {
- multi = curl_multi_init();
+ /* this multi handle will only ever have a single easy handled attached
+ to it, so make it use minimal hashes */
+ multi = Curl_multi_handle(1, 3);
if(!multi)
return CURLE_OUT_OF_MEMORY;
data->multi_easy = multi;
#define CURL_SOCKET_HASH_TABLE_SIZE 911
#endif
+#define CURL_CONNECTION_HASH_SIZE 97
#define CURL_MULTI_HANDLE 0x000bab1e
* per call."
*
*/
-static struct curl_hash *sh_init(void)
+static struct curl_hash *sh_init(int hashsize)
{
- return Curl_hash_alloc(CURL_SOCKET_HASH_TABLE_SIZE, hash_fd, fd_key_compare,
+ return Curl_hash_alloc(hashsize, hash_fd, fd_key_compare,
sh_freeentry);
}
(void)b;
}
-CURLM *curl_multi_init(void)
+struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
+ int chashsize) /* connection hash */
{
struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi));
if(!multi->hostcache)
goto error;
- multi->sockhash = sh_init();
+ multi->sockhash = sh_init(hashsize);
if(!multi->sockhash)
goto error;
- multi->conn_cache = Curl_conncache_init();
+ multi->conn_cache = Curl_conncache_init(chashsize);
if(!multi->conn_cache)
goto error;
return NULL;
}
+CURLM *curl_multi_init(void)
+{
+ return Curl_multi_handle(CURL_SOCKET_HASH_TABLE_SIZE,
+ CURL_CONNECTION_HASH_SIZE);
+}
+
+
CURLMcode curl_multi_add_handle(CURLM *multi_handle,
CURL *easy_handle)
{
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
*
***************************************************************************/
+
+
/*
* Prototypes for library-wide functions provided by multi.c
*/
bool Curl_multi_pipeline_enabled(const struct Curl_multi* multi);
void Curl_multi_handlePipeBreak(struct SessionHandle *data);
+/* Internal version of curl_multi_init() accepts size parameters for the
+ socket and connection hashes */
+struct Curl_multi *Curl_multi_handle(int hashsize, int chashsize);
+
/* the write bits start at bit 16 for the *getsock() bitmap */
#define GETSOCK_WRITEBITSTART 16