2012-12-10 20:04:13 +04:00
|
|
|
#ifndef HEADER_CURL_CONNCACHE_H
|
|
|
|
#define HEADER_CURL_CONNCACHE_H
|
2012-12-06 15:12:04 +04:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2019-04-05 17:38:36 +03:00
|
|
|
* Copyright (C) 2015 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2014-08-11 02:06:20 +04:00
|
|
|
* Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
|
2012-12-06 15:12:04 +04:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2016-02-03 02:19:02 +03:00
|
|
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
2012-12-06 15:12:04 +04:00
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2017-12-02 16:27:00 +03:00
|
|
|
/*
|
|
|
|
* All accesses to struct fields and changing of data in the connection cache
|
|
|
|
* and connectbundles must be done with the conncache LOCKED. The cache might
|
|
|
|
* be shared.
|
|
|
|
*/
|
|
|
|
|
2012-12-06 15:12:04 +04:00
|
|
|
struct conncache {
|
2015-05-12 10:15:02 +03:00
|
|
|
struct curl_hash hash;
|
2017-12-02 16:27:00 +03:00
|
|
|
size_t num_conn;
|
2014-07-23 14:05:47 +04:00
|
|
|
long next_connection_id;
|
2017-07-28 16:49:36 +03:00
|
|
|
struct curltime last_cleanup;
|
2017-11-02 01:37:45 +03:00
|
|
|
/* handle used for closing cached connections */
|
|
|
|
struct Curl_easy *closure_handle;
|
2012-12-06 15:12:04 +04:00
|
|
|
};
|
|
|
|
|
2015-05-18 09:56:29 +03:00
|
|
|
#define BUNDLE_NO_MULTIUSE -1
|
|
|
|
#define BUNDLE_UNKNOWN 0 /* initial value */
|
|
|
|
#define BUNDLE_MULTIPLEX 2
|
|
|
|
|
2015-05-13 00:06:11 +03:00
|
|
|
struct connectbundle {
|
2015-05-18 09:56:29 +03:00
|
|
|
int multiuse; /* supports multi-use */
|
2015-05-13 00:06:11 +03:00
|
|
|
size_t num_connections; /* Number of connections in the bundle */
|
2017-04-03 11:32:43 +03:00
|
|
|
struct curl_llist conn_list; /* The connectdata members of the bundle */
|
2015-05-13 00:06:11 +03:00
|
|
|
};
|
|
|
|
|
2017-11-02 01:37:45 +03:00
|
|
|
/* returns 1 on error, 0 is fine */
|
2015-05-12 10:15:02 +03:00
|
|
|
int Curl_conncache_init(struct conncache *, int size);
|
2012-12-06 15:12:04 +04:00
|
|
|
void Curl_conncache_destroy(struct conncache *connc);
|
|
|
|
|
2015-03-11 13:54:22 +03:00
|
|
|
/* return the correct bundle, to a host or a proxy */
|
|
|
|
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
|
2019-05-28 13:14:51 +03:00
|
|
|
struct conncache *connc,
|
|
|
|
const char **hostp);
|
2018-12-20 18:51:44 +03:00
|
|
|
void Curl_conncache_unlock(struct Curl_easy *data);
|
2017-12-02 16:27:00 +03:00
|
|
|
/* returns number of connections currently held in the connection cache */
|
|
|
|
size_t Curl_conncache_size(struct Curl_easy *data);
|
|
|
|
size_t Curl_conncache_bundle_size(struct connectdata *conn);
|
2012-12-06 15:12:04 +04:00
|
|
|
|
2017-12-02 16:27:00 +03:00
|
|
|
bool Curl_conncache_return_conn(struct connectdata *conn);
|
2012-12-06 15:12:04 +04:00
|
|
|
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
2018-06-25 00:22:35 +03:00
|
|
|
struct connectdata *conn) WARN_UNUSED_RESULT;
|
2018-12-20 18:39:02 +03:00
|
|
|
void Curl_conncache_remove_conn(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn,
|
2017-12-02 16:27:00 +03:00
|
|
|
bool lock);
|
|
|
|
bool Curl_conncache_foreach(struct Curl_easy *data,
|
2017-11-02 01:37:45 +03:00
|
|
|
struct conncache *connc,
|
2012-12-06 15:12:04 +04:00
|
|
|
void *param,
|
2012-12-11 23:13:29 +04:00
|
|
|
int (*func)(struct connectdata *conn,
|
|
|
|
void *param));
|
2012-12-06 15:12:04 +04:00
|
|
|
|
|
|
|
struct connectdata *
|
|
|
|
Curl_conncache_find_first_connection(struct conncache *connc);
|
|
|
|
|
2017-11-02 01:37:45 +03:00
|
|
|
struct connectdata *
|
2017-12-02 16:27:00 +03:00
|
|
|
Curl_conncache_extract_bundle(struct Curl_easy *data,
|
|
|
|
struct connectbundle *bundle);
|
|
|
|
struct connectdata *
|
|
|
|
Curl_conncache_extract_oldest(struct Curl_easy *data);
|
2017-11-02 01:37:45 +03:00
|
|
|
void Curl_conncache_close_all_connections(struct conncache *connc);
|
2012-12-06 15:12:04 +04:00
|
|
|
void Curl_conncache_print(struct conncache *connc);
|
|
|
|
|
2012-12-10 20:04:13 +04:00
|
|
|
#endif /* HEADER_CURL_CONNCACHE_H */
|