blob: 0b78de943bad5bdb241ba66038eb1d200d626a2a [file] [log] [blame]
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -07001#ifndef HEADER_CURL_MULTIHANDLE_H
2#define HEADER_CURL_MULTIHANDLE_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
Alex Deymod15eaac2016-06-28 14:49:26 -070014 * are also available at https://curl.haxx.se/docs/copyright.html.
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070015 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ***************************************************************************/
24
25#include "conncache.h"
26
27struct Curl_message {
28 /* the 'CURLMsg' is the part that is visible to the external user */
29 struct CURLMsg extmsg;
30};
31
32/* NOTE: if you add a state here, add the name to the statename[] array as
33 well!
34*/
35typedef enum {
36 CURLM_STATE_INIT, /* 0 - start in this state */
37 CURLM_STATE_CONNECT_PEND, /* 1 - no connections, waiting for one */
38 CURLM_STATE_CONNECT, /* 2 - resolve/connect has been sent off */
39 CURLM_STATE_WAITRESOLVE, /* 3 - awaiting the resolve to finalize */
40 CURLM_STATE_WAITCONNECT, /* 4 - awaiting the TCP connect to finalize */
Elliott Hughescee03382017-06-23 12:17:18 -070041 CURLM_STATE_WAITPROXYCONNECT, /* 5 - awaiting HTTPS proxy SSL initialization
42 to complete and/or proxy CONNECT to
43 finalize */
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070044 CURLM_STATE_SENDPROTOCONNECT, /* 6 - initiate protocol connect procedure */
45 CURLM_STATE_PROTOCONNECT, /* 7 - completing the protocol-specific connect
46 phase */
47 CURLM_STATE_WAITDO, /* 8 - wait for our turn to send the request */
48 CURLM_STATE_DO, /* 9 - start send off the request (part 1) */
49 CURLM_STATE_DOING, /* 10 - sending off the request (part 1) */
50 CURLM_STATE_DO_MORE, /* 11 - send off the request (part 2) */
51 CURLM_STATE_DO_DONE, /* 12 - done sending off request */
52 CURLM_STATE_WAITPERFORM, /* 13 - wait for our turn to read the response */
53 CURLM_STATE_PERFORM, /* 14 - transfer data */
54 CURLM_STATE_TOOFAST, /* 15 - wait because limit-rate exceeded */
55 CURLM_STATE_DONE, /* 16 - post data transfer operation */
56 CURLM_STATE_COMPLETED, /* 17 - operation complete */
57 CURLM_STATE_MSGSENT, /* 18 - the operation complete message is sent */
58 CURLM_STATE_LAST /* 19 - not a true state, never use this */
59} CURLMstate;
60
61/* we support N sockets per easy handle. Set the corresponding bit to what
62 action we should wait for */
63#define MAX_SOCKSPEREASYHANDLE 5
64#define GETSOCK_READABLE (0x00ff)
65#define GETSOCK_WRITABLE (0xff00)
66
67#define CURLPIPE_ANY (CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX)
68
69/* This is the struct known as CURLM on the outside */
70struct Curl_multi {
71 /* First a simple identifier to easier detect if a user mix up
72 this multi handle with an easy handle. Set this to CURL_MULTI_HANDLE. */
73 long type;
74
75 /* We have a doubly-linked circular list with easy handles */
Alex Deymoe3149cc2016-10-05 11:18:42 -070076 struct Curl_easy *easyp;
77 struct Curl_easy *easylp; /* last node */
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070078
79 int num_easy; /* amount of entries in the linked list above. */
80 int num_alive; /* amount of easy handles that are added but have not yet
81 reached COMPLETE state */
82
83 struct curl_llist *msglist; /* a list of messages from completed transfers */
84
Alex Deymoe3149cc2016-10-05 11:18:42 -070085 struct curl_llist *pending; /* Curl_easys that are in the
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070086 CURLM_STATE_CONNECT_PEND state */
87
88 /* callback function and user data pointer for the *socket() API */
89 curl_socket_callback socket_cb;
90 void *socket_userp;
91
Alex Deymod15eaac2016-06-28 14:49:26 -070092 /* callback function and user data pointer for server push */
93 curl_push_callback push_cb;
94 void *push_userp;
95
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070096 /* Hostname cache */
97 struct curl_hash hostcache;
98
99 /* timetree points to the splay-tree of time nodes to figure out expire
100 times of all currently set timers */
101 struct Curl_tree *timetree;
102
103 /* 'sockhash' is the lookup hash for socket descriptor => easy handles (note
104 the pluralis form, there can be more than one easy handle waiting on the
105 same actual socket) */
106 struct curl_hash sockhash;
107
108 /* pipelining wanted bits (CURLPIPE*) */
109 long pipelining;
110
111 bool recheckstate; /* see Curl_multi_connchanged */
112
113 /* Shared connection cache (bundles)*/
114 struct conncache conn_cache;
115
116 /* This handle will be used for closing the cached connections in
117 curl_multi_cleanup() */
Alex Deymoe3149cc2016-10-05 11:18:42 -0700118 struct Curl_easy *closure_handle;
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700119
120 long maxconnects; /* if >0, a fixed limit of the maximum number of entries
121 we're allowed to grow the connection cache to */
122
123 long max_host_connections; /* if >0, a fixed limit of the maximum number
124 of connections per host */
125
126 long max_total_connections; /* if >0, a fixed limit of the maximum number
127 of connections in total */
128
129 long max_pipeline_length; /* if >0, maximum number of requests in a
130 pipeline */
131
132 long content_length_penalty_size; /* a connection with a
133 content-length bigger than
134 this is not considered
135 for pipelining */
136
137 long chunk_length_penalty_size; /* a connection with a chunk length
138 bigger than this is not
139 considered for pipelining */
140
141 struct curl_llist *pipelining_site_bl; /* List of sites that are blacklisted
142 from pipelining */
143
144 struct curl_llist *pipelining_server_bl; /* List of server types that are
145 blacklisted from pipelining */
146
147 /* timer callback and user data pointer for the *socket() API */
148 curl_multi_timer_callback timer_cb;
149 void *timer_userp;
150 struct timeval timer_lastcall; /* the fixed time for the timeout for the
151 previous callback */
152};
153
154#endif /* HEADER_CURL_MULTIHANDLE_H */