當前位置: 首頁>>代碼示例>>C++>>正文


C++ Curl_share_unlock函數代碼示例

本文整理匯總了C++中Curl_share_unlock函數的典型用法代碼示例。如果您正苦於以下問題:C++ Curl_share_unlock函數的具體用法?C++ Curl_share_unlock怎麽用?C++ Curl_share_unlock使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Curl_share_unlock函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: Curl_resolv_unlock

/*
 * Curl_resolv_unlock() unlocks the given cached DNS entry. When this has been
 * made, the struct may be destroyed due to pruning. It is important that only
 * one unlock is made for each Curl_resolv() call.
 *
 * May be called with 'data' == NULL for global cache.
 */
void Curl_resolv_unlock(struct Curl_easy *data, struct Curl_dns_entry *dns)
{
  if(data && data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  freednsentry(dns);

  if(data && data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
開發者ID:2px,項目名稱:curl,代碼行數:17,代碼來源:hostip.c

示例2: Curl_hostcache_clean

void Curl_hostcache_clean(struct SessionHandle *data,
                          struct curl_hash *hash)
{
  if(data && data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  Curl_hash_clean(hash);

  if(data && data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
開發者ID:54chen,項目名稱:curl,代碼行數:11,代碼來源:hostip.c

示例3: Curl_resolv_unlock

/*
 * Curl_resolv_unlock() unlocks the given cached DNS entry. When this has been
 * made, the struct may be destroyed due to pruning. It is important that only
 * one unlock is made for each Curl_resolv() call.
 */
void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns)
{
  curlassert(dns && (dns->inuse>0));

  if(data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  dns->inuse--;

  if(data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
開發者ID:rogerclark,項目名稱:grumble,代碼行數:17,代碼來源:hostip.c

示例4: addrinfo_callback

/*
 * addrinfo_callback() gets called by ares, gethostbyname_thread() or
 * getaddrinfo_thread() when we got the name resolved (or not!).
 *
 * If the status argument is CURL_ASYNC_SUCCESS, we might need to copy the
 * address field since it might be freed when this function returns. This
 * operation stores the resolved data in the DNS cache.
 *
 * NOTE: for IPv6 operations, Curl_addrinfo_copy() returns the same
 * pointer it is given as argument!
 *
 * The storage operation locks and unlocks the DNS cache.
 */
static CURLcode addrinfo_callback(void *arg, /* "struct connectdata *" */
                                  int status,
                                  void *addr)
{
  struct connectdata *conn = (struct connectdata *)arg;
  struct Curl_dns_entry *dns = NULL;
  CURLcode rc = CURLE_OK;

  conn->async.status = status;

  if(CURL_ASYNC_SUCCESS == status) {

    /*
     * IPv4/ares: Curl_addrinfo_copy() copies the address and returns an
     * allocated version.
     *
     * IPv6: Curl_addrinfo_copy() returns the input pointer!
     */
    Curl_addrinfo *ai = Curl_addrinfo_copy(addr, conn->async.port);
    if(ai) {
      struct SessionHandle *data = conn->data;

      if(data->share)
        Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

      dns = Curl_cache_addr(data, ai,
                            conn->async.hostname,
                            conn->async.port);
      if(!dns) {
        /* failed to store, cleanup and return error */
        Curl_freeaddrinfo(ai);
        rc = CURLE_OUT_OF_MEMORY;
      }

      if(data->share)
        Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
    }
    else
      rc = CURLE_OUT_OF_MEMORY;
  }

  conn->async.dns = dns;

 /* Set async.done TRUE last in this function since it may be used multi-
    threaded and once this is TRUE the other thread may read fields from the
    async struct */
  conn->async.done = TRUE;

  /* ipv4: The input hostent struct will be freed by ares when we return from
     this function */
  return rc;
}
開發者ID:RayPlante,項目名稱:usvirtualobservatory,代碼行數:65,代碼來源:hostasyn.c

示例5: Curl_ssl_getsessionid

/*
 * Check if there's a session ID for the given connection in the cache, and if
 * there's one suitable, it is provided. Returns TRUE when no entry matched.
 */
int Curl_ssl_getsessionid(struct connectdata *conn,
                          void **ssl_sessionid,
                          size_t *idsize) /* set 0 if unknown */
{
    struct curl_ssl_session *check;
    struct SessionHandle *data = conn->data;
    size_t i;
    long *general_age;
    bool no_match = TRUE;

    *ssl_sessionid = NULL;

    if(!conn->ssl_config.sessionid)
        /* session ID re-use is disabled */
        return TRUE;

    /* Lock if shared */
    if(SSLSESSION_SHARED(data)) {
        Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SINGLE);
        general_age = &data->share->sessionage;
    }
    else
        general_age = &data->state.sessionage;

    for(i = 0; i < data->set.ssl.max_ssl_sessions; i++) {
        check = &data->state.session[i];
        if(!check->sessionid)
            /* not session ID means blank entry */
            continue;
        if(Curl_raw_equal(conn->host.name, check->name) &&
                (conn->remote_port == check->remote_port) &&
                Curl_ssl_config_matches(&conn->ssl_config, &check->ssl_config)) {
            /* yes, we have a session ID! */
            (*general_age)++;          /* increase general age */
            check->age = *general_age; /* set this as used in this age */
            *ssl_sessionid = check->sessionid;
            if(idsize)
                *idsize = check->idsize;
            no_match = FALSE;
            break;
        }
    }

    /* Unlock */
    if(SSLSESSION_SHARED(data))
        Curl_share_unlock(data, CURL_LOCK_DATA_SSL_SESSION);

    return no_match;
}
開發者ID:jerywang,項目名稱:curl,代碼行數:53,代碼來源:sslgen.c

示例6: Curl_resolv_unlock

void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns)
{
  if(data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  dns->inuse--;

#ifdef CURLDEBUG
  if(dns->inuse < 0) {
    infof(data, "Interal host cache screw-up!");
    *(char **)0=NULL;
  }
#endif

  if(data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
開發者ID:tankorsmash,項目名稱:quadcow,代碼行數:17,代碼來源:hostip.c

示例7: Curl_cookie_loadfiles

/*
 * Load cookies from all given cookie files (CURLOPT_COOKIEFILE).
 */
void Curl_cookie_loadfiles(struct SessionHandle *data)
{
  struct curl_slist *list = data->change.cookielist;
  if(list) {
    Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
    while(list) {
      data->cookies = Curl_cookie_init(data,
                                       list->data,
                                       data->cookies,
                                       data->set.cookiesession);
      list = list->next;
    }
    curl_slist_free_all(data->change.cookielist); /* clean up list */
    data->change.cookielist = NULL; /* don't do this again! */
    Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
  }
}
開發者ID:AdiBoy,項目名稱:mtasa-blue,代碼行數:20,代碼來源:cookie.c

示例8: Curl_resolv_unlock

/*
 * Curl_resolv_unlock() unlocks the given cached DNS entry. When this has been
 * made, the struct may be destroyed due to pruning. It is important that only
 * one unlock is made for each Curl_resolv() call.
 */
void Curl_resolv_unlock(struct SessionHandle *data, struct Curl_dns_entry *dns)
{
  DEBUGASSERT(dns && (dns->inuse>0));

  if(data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  dns->inuse--;
  /* only free if nobody is using AND it is not in hostcache (timestamp ==
     0) */
  if (dns->inuse == 0 && dns->timestamp == 0) {
    Curl_freeaddrinfo(dns->addr);
    free(dns);
  }

  if(data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
開發者ID:1007650105,項目名稱:aseprite,代碼行數:23,代碼來源:hostip.c

示例9: Curl_addrinfo_callback

/*
 * Curl_addrinfo_callback() gets called by ares, gethostbyname_thread()
 * or getaddrinfo_thread() when we got the name resolved (or not!).
 *
 * If the status argument is CURL_ASYNC_SUCCESS, this function takes
 * ownership of the Curl_addrinfo passed, storing the resolved data
 * in the DNS cache.
 *
 * The storage operation locks and unlocks the DNS cache.
 */
CURLcode Curl_addrinfo_callback(struct connectdata *conn,
                                int status,
                                struct Curl_addrinfo *ai)
{
    struct Curl_dns_entry *dns = NULL;
    CURLcode result = CURLE_OK;

    conn->async.status = status;

    if(CURL_ASYNC_SUCCESS == status) {
        if(ai) {
            struct SessionHandle *data = conn->data;

            if(data->share)
                Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

            dns = Curl_cache_addr(data, ai,
                                  conn->async.hostname,
                                  conn->async.port);
            if(!dns) {
                /* failed to store, cleanup and return error */
                Curl_freeaddrinfo(ai);
                result = CURLE_OUT_OF_MEMORY;
            }

            if(data->share)
                Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
        }
        else {
            result = CURLE_OUT_OF_MEMORY;
        }
    }

    conn->async.dns = dns;

    /* Set async.done TRUE last in this function since it may be used multi-
       threaded and once this is TRUE the other thread may read fields from the
       async struct */
    conn->async.done = TRUE;

    /* IPv4: The input hostent struct will be freed by ares when we return from
       this function */
    return result;
}
開發者ID:robn,項目名稱:pioneer-thirdparty,代碼行數:54,代碼來源:hostasyn.c

示例10: Curl_ssl_getsessionid

/*
 * Check if there's a session ID for the given connection in the cache, and if
 * there's one suitable, it is provided. Returns TRUE when no entry matched.
 */
int Curl_ssl_getsessionid(struct connectdata *conn,
                          void **ssl_sessionid,
                          size_t *idsize) /* set 0 if unknown */
{
  struct curl_ssl_session *check;
  struct SessionHandle *data = conn->data;
  long i;

  if(!conn->ssl_config.sessionid)
    /* session ID re-use is disabled */
    return TRUE;

  /* Lock for reading if shared */
  if(data->share && data->share->sslsession == data->state.session)
    Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SHARED);

  for(i=0; i< data->set.ssl.numsessions; i++) {
    check = &data->state.session[i];
    if(!check->sessionid)
      /* not session ID means blank entry */
      continue;
    if(Curl_raw_equal(conn->host.name, check->name) &&
       (conn->remote_port == check->remote_port) &&
       Curl_ssl_config_matches(&conn->ssl_config, &check->ssl_config)) {
      /* yes, we have a session ID! */
      data->state.sessionage++;            /* increase general age */
      check->age = data->state.sessionage; /* set this as used in this age */
      *ssl_sessionid = check->sessionid;
      if(idsize)
        *idsize = check->idsize;
      return FALSE;
    }
  }
  *ssl_sessionid = NULL;

  /* Unlock for reading */
  if(data->share && data->share->sslsession == data->state.session)
    Curl_share_unlock(data, CURL_LOCK_DATA_SSL_SESSION);


  return TRUE;
}
開發者ID:Ashod,項目名稱:WinCairoRequirements,代碼行數:46,代碼來源:sslgen.c

示例11: Curl_fetch_addr

/*
 * Curl_fetch_addr() fetches a 'Curl_dns_entry' already in the DNS cache.
 *
 * Curl_resolv() checks initially and multi_runsingle() checks each time
 * it discovers the handle in the state WAITRESOLVE whether the hostname
 * has already been resolved and the address has already been stored in
 * the DNS cache. This short circuits waiting for a lot of pending
 * lookups for the same hostname requested by different handles.
 *
 * Returns the Curl_dns_entry entry pointer or NULL if not in the cache.
 *
 * The returned data *MUST* be "unlocked" with Curl_resolv_unlock() after
 * use, or we'll leak memory!
 */
struct Curl_dns_entry *
Curl_fetch_addr(struct connectdata *conn,
                const char *hostname,
                int port)
{
  struct SessionHandle *data = conn->data;
  struct Curl_dns_entry *dns = NULL;

  if(data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  dns = fetch_addr(conn, hostname, port);

  if(dns) dns->inuse++; /* we use it! */

  if(data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);

  return dns;
}
開發者ID:601040605,項目名稱:WNetLicensor,代碼行數:34,代碼來源:hostip.c

示例12: Curl_ssl_delsessionid

/*
 * Delete the given session ID from the cache.
 */
void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid)
{
    size_t i;
    struct SessionHandle *data=conn->data;

    if(SSLSESSION_SHARED(data))
        Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SINGLE);

    for(i = 0; i < data->set.ssl.max_ssl_sessions; i++) {
        struct curl_ssl_session *check = &data->state.session[i];

        if(check->sessionid == ssl_sessionid) {
            Curl_ssl_kill_session(check);
            break;
        }
    }

    if(SSLSESSION_SHARED(data))
        Curl_share_unlock(data, CURL_LOCK_DATA_SSL_SESSION);
}
開發者ID:jerywang,項目名稱:curl,代碼行數:23,代碼來源:sslgen.c

示例13: Curl_hostcache_prune

void Curl_hostcache_prune(struct SessionHandle *data)
{
  time_t now;

  if(data->set.dns_cache_timeout == -1)
    /* cache forever means never prune! */
    return;

  if(data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  time(&now);

  /* Remove outdated and unused entries from the hostcache */
  hostcache_prune(data->hostcache,
                  data->set.dns_cache_timeout,
                  now);

  if(data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
開發者ID:tankorsmash,項目名稱:quadcow,代碼行數:21,代碼來源:hostip.c

示例14: Curl_ssl_close_all

void Curl_ssl_close_all(struct SessionHandle *data)
{
  long i;
  /* kill the session ID cache */
  if(data->state.session &&
     !(data->share && data->share->sslsession == data->state.session)) {

    Curl_share_lock(data, CURL_LOCK_DATA_SSL_SESSION, CURL_LOCK_ACCESS_SINGLE);

    for(i=0; i< data->set.ssl.numsessions; i++)
      /* the single-killer function handles empty table slots */
      Curl_ssl_kill_session(&data->state.session[i]);

    /* free the cache data */
    free(data->state.session);
    data->state.session = NULL;

    Curl_share_unlock(data, CURL_LOCK_DATA_SSL_SESSION);
  }

  curlssl_close_all(data);
}
開發者ID:Ashod,項目名稱:WinCairoRequirements,代碼行數:22,代碼來源:sslgen.c

示例15: Curl_hostcache_prune

/*
 * Library-wide function for pruning the DNS cache. This function takes and
 * returns the appropriate locks.
 */
void Curl_hostcache_prune(struct Curl_easy *data)
{
  time_t now;

  if((data->set.dns_cache_timeout == -1) || !data->dns.hostcache)
    /* cache forever means never prune, and NULL hostcache means
       we can't do it */
    return;

  if(data->share)
    Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);

  time(&now);

  /* Remove outdated and unused entries from the hostcache */
  hostcache_prune(data->dns.hostcache,
                  data->set.dns_cache_timeout,
                  now);

  if(data->share)
    Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
開發者ID:FunTW,項目名稱:terminal,代碼行數:26,代碼來源:hostip.c


注:本文中的Curl_share_unlock函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。