VirtualBox

source: vbox/trunk/src/libs/curl-7.87.0/lib/conncache.h@ 99040

最後變更 在這個檔案從99040是 98326,由 vboxsync 提交於 2 年 前

curl-7.87.0: Applied and adjusted our curl changes to 7.83.1. bugref:10356

  • 屬性 svn:eol-style 設為 native
檔案大小: 5.1 KB
 
1#ifndef HEADER_CURL_CONNCACHE_H
2#define HEADER_CURL_CONNCACHE_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 2015 - 2022, Daniel Stenberg, <[email protected]>, et al.
11 * Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <[email protected]>
12 *
13 * This software is licensed as described in the file COPYING, which
14 * you should have received as part of this distribution. The terms
15 * are also available at https://curl.se/docs/copyright.html.
16 *
17 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
18 * copies of the Software, and permit persons to whom the Software is
19 * furnished to do so, under the terms of the COPYING file.
20 *
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
23 *
24 * SPDX-License-Identifier: curl
25 *
26 ***************************************************************************/
27
28/*
29 * All accesses to struct fields and changing of data in the connection cache
30 * and connectbundles must be done with the conncache LOCKED. The cache might
31 * be shared.
32 */
33
34#include <curl/curl.h>
35#include "timeval.h"
36
37struct connectdata;
38
39struct conncache {
40 struct Curl_hash hash;
41 size_t num_conn;
42 long next_connection_id;
43 struct curltime last_cleanup;
44 /* handle used for closing cached connections */
45 struct Curl_easy *closure_handle;
46};
47
48#define BUNDLE_NO_MULTIUSE -1
49#define BUNDLE_UNKNOWN 0 /* initial value */
50#define BUNDLE_MULTIPLEX 2
51
52#ifdef CURLDEBUG
53/* the debug versions of these macros make extra certain that the lock is
54 never doubly locked or unlocked */
55#define CONNCACHE_LOCK(x) \
56 do { \
57 if((x)->share) { \
58 Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, \
59 CURL_LOCK_ACCESS_SINGLE); \
60 DEBUGASSERT(!(x)->state.conncache_lock); \
61 (x)->state.conncache_lock = TRUE; \
62 } \
63 } while(0)
64
65#define CONNCACHE_UNLOCK(x) \
66 do { \
67 if((x)->share) { \
68 DEBUGASSERT((x)->state.conncache_lock); \
69 (x)->state.conncache_lock = FALSE; \
70 Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT); \
71 } \
72 } while(0)
73#else
74#define CONNCACHE_LOCK(x) if((x)->share) \
75 Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE)
76#define CONNCACHE_UNLOCK(x) if((x)->share) \
77 Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT)
78#endif
79
80struct connectbundle {
81 int multiuse; /* supports multi-use */
82 size_t num_connections; /* Number of connections in the bundle */
83 struct Curl_llist conn_list; /* The connectdata members of the bundle */
84};
85
86/* returns 1 on error, 0 is fine */
87int Curl_conncache_init(struct conncache *, int size);
88void Curl_conncache_destroy(struct conncache *connc);
89
90/* return the correct bundle, to a host or a proxy */
91struct connectbundle *Curl_conncache_find_bundle(struct Curl_easy *data,
92 struct connectdata *conn,
93 struct conncache *connc);
94/* returns number of connections currently held in the connection cache */
95size_t Curl_conncache_size(struct Curl_easy *data);
96
97bool Curl_conncache_return_conn(struct Curl_easy *data,
98 struct connectdata *conn);
99CURLcode Curl_conncache_add_conn(struct Curl_easy *data) WARN_UNUSED_RESULT;
100void Curl_conncache_remove_conn(struct Curl_easy *data,
101 struct connectdata *conn,
102 bool lock);
103bool Curl_conncache_foreach(struct Curl_easy *data,
104 struct conncache *connc,
105 void *param,
106 int (*func)(struct Curl_easy *data,
107 struct connectdata *conn,
108 void *param));
109
110struct connectdata *
111Curl_conncache_find_first_connection(struct conncache *connc);
112
113struct connectdata *
114Curl_conncache_extract_bundle(struct Curl_easy *data,
115 struct connectbundle *bundle);
116struct connectdata *
117Curl_conncache_extract_oldest(struct Curl_easy *data);
118void Curl_conncache_close_all_connections(struct conncache *connc);
119void Curl_conncache_print(struct conncache *connc);
120
121#endif /* HEADER_CURL_CONNCACHE_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette