Exemplo n.º 1
0
struct conncache *Curl_conncache_init(int size)
{
  struct conncache *connc;

  connc = calloc(1, sizeof(struct conncache));
  if(!connc)
    return NULL;

  connc->hash = Curl_hash_alloc(size, Curl_hash_str,
                                Curl_str_key_compare, free_bundle_hash_entry);

  if(!connc->hash) {
    free(connc);
    return NULL;
  }

  return connc;
}
Exemplo n.º 2
0
struct conncache *Curl_conncache_init(void)
{
  struct conncache *connc;

  connc = calloc(1, sizeof(struct conncache));
  if(!connc)
    return NULL;

  connc->hash = Curl_hash_alloc(CONNECTION_HASH_SIZE, Curl_hash_str,
                                Curl_str_key_compare, free_bundle_hash_entry);

  if(!connc->hash) {
    free(connc);
    return NULL;
  }

  return connc;
}
Exemplo n.º 3
0
struct conncache *Curl_conncache_init(conncachetype type)
{
  struct conncache *connc;

  connc = calloc(1, sizeof(struct conncache));
  if(!connc)
    return NULL;

  connc->hash = Curl_hash_alloc(CONNECTION_HASH_SIZE, Curl_hash_str,
                                Curl_str_key_compare, free_bundle_hash_entry);

  if(!connc->hash) {
    free(connc);
    return NULL;
  }

  connc->type = type;
  connc->num_connections = 0;

  return connc;
}
Exemplo n.º 4
0
/*
 * Curl_mk_dnscache() creates a new DNS cache and returns the handle for it.
 */
struct curl_hash *Curl_mk_dnscache(void)
{
  return Curl_hash_alloc(7, Curl_hash_str, Curl_str_key_compare, freednsentry);
}
Exemplo n.º 5
0
/*
 * Curl_mk_dnscache() creates a new DNS cache and returns the handle for it.
 */
struct curl_hash *Curl_mk_dnscache(void)
{
  return Curl_hash_alloc(7, freednsentry);
}
Exemplo n.º 6
0
CURLSHcode
curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
{
    struct Curl_share *share = (struct Curl_share *)sh;
    va_list param;
    int type;
    curl_lock_function lockfunc;
    curl_unlock_function unlockfunc;
    void *ptr;

    if (share->dirty)
        /* don't allow setting options while one or more handles are already
           using this share */
        return CURLSHE_IN_USE;

    va_start(param, option);

    switch(option)
    {
    case CURLSHOPT_SHARE:
        /* this is a type this share will share */
        type = va_arg(param, int);
        share->specifier |= (1<<type);
        switch( type )
        {
        case CURL_LOCK_DATA_DNS:
            if (!share->hostcache)
            {
                share->hostcache = Curl_hash_alloc(7, Curl_freednsinfo);
            }
            break;

        case CURL_LOCK_DATA_COOKIE:
            if (!share->cookies)
            {
                share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE );
            }
            break;

        case CURL_LOCK_DATA_SSL_SESSION:
            break;

        case CURL_LOCK_DATA_CONNECT:
            break;

        default:
            return CURLSHE_BAD_OPTION;
        }
        break;

    case CURLSHOPT_UNSHARE:
        /* this is a type this share will no longer share */
        type = va_arg(param, int);
        share->specifier &= ~(1<<type);
        switch( type )
        {
        case CURL_LOCK_DATA_DNS:
            if (share->hostcache)
            {
                Curl_hash_destroy(share->hostcache);
                share->hostcache = NULL;
            }
            break;

        case CURL_LOCK_DATA_COOKIE:
            if (share->cookies)
            {
                Curl_cookie_cleanup(share->cookies);
                share->cookies = NULL;
            }
            break;

        case CURL_LOCK_DATA_SSL_SESSION:
            break;

        case CURL_LOCK_DATA_CONNECT:
            break;

        default:
            return CURLSHE_BAD_OPTION;
        }
        break;

    case CURLSHOPT_LOCKFUNC:
        lockfunc = va_arg(param, curl_lock_function);
        share->lockfunc = lockfunc;
        break;

    case CURLSHOPT_UNLOCKFUNC:
        unlockfunc = va_arg(param, curl_unlock_function);
        share->unlockfunc = unlockfunc;
        break;

    case CURLSHOPT_USERDATA:
        ptr = va_arg(param, void *);
        share->clientdata = ptr;
        break;

    default:
        return CURLSHE_BAD_OPTION;
    }

    return CURLSHE_OK;
}