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 ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2017-04-03 11:32:43 +03:00
|
|
|
* Copyright (C) 2015 - 2017, 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.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
struct conncache {
|
2015-05-12 10:15:02 +03:00
|
|
|
struct curl_hash hash;
|
2012-12-06 15:12:04 +04:00
|
|
|
size_t num_connections;
|
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_PIPELINING 1
|
|
|
|
#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,
|
|
|
|
struct conncache *connc);
|
2012-12-06 15:12:04 +04:00
|
|
|
|
|
|
|
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
|
|
|
struct connectdata *conn);
|
|
|
|
|
|
|
|
void Curl_conncache_remove_conn(struct conncache *connc,
|
|
|
|
struct connectdata *conn);
|
|
|
|
|
2017-11-02 01:37:45 +03:00
|
|
|
void Curl_conncache_foreach(struct Curl_easy *data,
|
|
|
|
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 *
|
|
|
|
Curl_conncache_oldest_idle(struct Curl_easy *data);
|
|
|
|
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 */
|