2012-12-10 11:04:13 -05:00
|
|
|
#ifndef HEADER_CURL_CONNCACHE_H
|
|
|
|
#define HEADER_CURL_CONNCACHE_H
|
2012-12-06 06:12:04 -05:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2017-04-03 04:32:43 -04:00
|
|
|
* Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2014-08-10 18:06:20 -04:00
|
|
|
* Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
|
2012-12-06 06:12:04 -05: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-02 18:19:02 -05:00
|
|
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
2012-12-06 06:12:04 -05: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 08:27:00 -05: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 06:12:04 -05:00
|
|
|
struct conncache {
|
2015-05-12 03:15:02 -04:00
|
|
|
struct curl_hash hash;
|
2017-12-02 08:27:00 -05:00
|
|
|
size_t num_conn;
|
2014-07-23 06:05:47 -04:00
|
|
|
long next_connection_id;
|
2017-07-28 09:49:36 -04:00
|
|
|
struct curltime last_cleanup;
|
2017-11-01 18:37:45 -04:00
|
|
|
/* handle used for closing cached connections */
|
|
|
|
struct Curl_easy *closure_handle;
|
2012-12-06 06:12:04 -05:00
|
|
|
};
|
|
|
|
|
2015-05-18 02:56:29 -04:00
|
|
|
#define BUNDLE_NO_MULTIUSE -1
|
|
|
|
#define BUNDLE_UNKNOWN 0 /* initial value */
|
|
|
|
#define BUNDLE_PIPELINING 1
|
|
|
|
#define BUNDLE_MULTIPLEX 2
|
|
|
|
|
2015-05-12 17:06:11 -04:00
|
|
|
struct connectbundle {
|
2015-05-18 02:56:29 -04:00
|
|
|
int multiuse; /* supports multi-use */
|
2015-05-12 17:06:11 -04:00
|
|
|
size_t num_connections; /* Number of connections in the bundle */
|
2017-04-03 04:32:43 -04:00
|
|
|
struct curl_llist conn_list; /* The connectdata members of the bundle */
|
2015-05-12 17:06:11 -04:00
|
|
|
};
|
|
|
|
|
2017-11-01 18:37:45 -04:00
|
|
|
/* returns 1 on error, 0 is fine */
|
2015-05-12 03:15:02 -04:00
|
|
|
int Curl_conncache_init(struct conncache *, int size);
|
2012-12-06 06:12:04 -05:00
|
|
|
void Curl_conncache_destroy(struct conncache *connc);
|
|
|
|
|
2015-03-11 06:54:22 -04:00
|
|
|
/* return the correct bundle, to a host or a proxy */
|
|
|
|
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
|
|
|
|
struct conncache *connc);
|
2017-12-02 08:27:00 -05:00
|
|
|
void Curl_conncache_unlock(struct connectdata *conn);
|
|
|
|
/* 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 06:12:04 -05:00
|
|
|
|
2017-12-02 08:27:00 -05:00
|
|
|
bool Curl_conncache_return_conn(struct connectdata *conn);
|
2012-12-06 06:12:04 -05:00
|
|
|
CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
|
|
|
struct connectdata *conn);
|
2017-12-02 08:27:00 -05:00
|
|
|
void Curl_conncache_remove_conn(struct connectdata *conn,
|
|
|
|
bool lock);
|
|
|
|
bool Curl_conncache_foreach(struct Curl_easy *data,
|
2017-11-01 18:37:45 -04:00
|
|
|
struct conncache *connc,
|
2012-12-06 06:12:04 -05:00
|
|
|
void *param,
|
2012-12-11 14:13:29 -05:00
|
|
|
int (*func)(struct connectdata *conn,
|
|
|
|
void *param));
|
2012-12-06 06:12:04 -05:00
|
|
|
|
|
|
|
struct connectdata *
|
|
|
|
Curl_conncache_find_first_connection(struct conncache *connc);
|
|
|
|
|
2017-11-01 18:37:45 -04:00
|
|
|
struct connectdata *
|
2017-12-02 08:27:00 -05:00
|
|
|
Curl_conncache_extract_bundle(struct Curl_easy *data,
|
|
|
|
struct connectbundle *bundle);
|
|
|
|
struct connectdata *
|
|
|
|
Curl_conncache_extract_oldest(struct Curl_easy *data);
|
2017-11-01 18:37:45 -04:00
|
|
|
void Curl_conncache_close_all_connections(struct conncache *connc);
|
2012-12-06 06:12:04 -05:00
|
|
|
void Curl_conncache_print(struct conncache *connc);
|
|
|
|
|
2012-12-10 11:04:13 -05:00
|
|
|
#endif /* HEADER_CURL_CONNCACHE_H */
|