Debian Codegraph @

deps/curl/lib/multihandle.h

raw
1 #ifndef HEADER_CURL_MULTIHANDLE_H
2 #define HEADER_CURL_MULTIHANDLE_H
3 /***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, 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
14 * are also available at https://curl.haxx.se/docs/copyright.html.
15 *
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 #include "psl.h"
27 #include "socketpair.h"
28
29 struct Curl_message {
30 struct curl_llist_element list;
31 /* the 'CURLMsg' is the part that is visible to the external user */
32 struct CURLMsg extmsg;
33 };
34
35 /* NOTE: if you add a state here, add the name to the statename[] array as
36 well!
37 */
38 typedef enum {
39 CURLM_STATE_INIT, /* 0 - start in this state */
40 CURLM_STATE_CONNECT_PEND, /* 1 - no connections, waiting for one */
41 CURLM_STATE_CONNECT, /* 2 - resolve/connect has been sent off */
42 CURLM_STATE_WAITRESOLVE, /* 3 - awaiting the resolve to finalize */
43 CURLM_STATE_WAITCONNECT, /* 4 - awaiting the TCP connect to finalize */
44 CURLM_STATE_WAITPROXYCONNECT, /* 5 - awaiting HTTPS proxy SSL initialization
45 to complete and/or proxy CONNECT to
46 finalize */
47 CURLM_STATE_SENDPROTOCONNECT, /* 6 - initiate protocol connect procedure */
48 CURLM_STATE_PROTOCONNECT, /* 7 - completing the protocol-specific connect
49 phase */
50 CURLM_STATE_DO, /* 8 - start send off the request (part 1) */
51 CURLM_STATE_DOING, /* 9 - sending off the request (part 1) */
52 CURLM_STATE_DO_MORE, /* 10 - send off the request (part 2) */
53 CURLM_STATE_DO_DONE, /* 11 - done sending off request */
54 CURLM_STATE_PERFORM, /* 12 - transfer data */
55 CURLM_STATE_TOOFAST, /* 13 - wait because limit-rate exceeded */
56 CURLM_STATE_DONE, /* 14 - post data transfer operation */
57 CURLM_STATE_COMPLETED, /* 15 - operation complete */
58 CURLM_STATE_MSGSENT, /* 16 - the operation complete message is sent */
59 CURLM_STATE_LAST /* 17 - not a true state, never use this */
60 } CURLMstate;
61
62 /* we support N sockets per easy handle. Set the corresponding bit to what
63 action we should wait for */
64 #define MAX_SOCKSPEREASYHANDLE 5
65 #define GETSOCK_READABLE (0x00ff)
66 #define GETSOCK_WRITABLE (0xff00)
67
68 #define CURLPIPE_ANY (CURLPIPE_MULTIPLEX)
69
70 #if defined(USE_SOCKETPAIR) && !defined(USE_BLOCKING_SOCKETS)
71 #define ENABLE_WAKEUP
72 #endif
73
74
75 /* value for MAXIMUM CONCURRENT STREAMS upper limit */
76 #define INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1)
77
78 /* This is the struct known as CURLM on the outside */
79 struct Curl_multi {
80 /* First a simple identifier to easier detect if a user mix up
81 this multi handle with an easy handle. Set this to CURL_MULTI_HANDLE. */
82 long type;
83
84 /* We have a doubly-linked circular list with easy handles */
85 struct Curl_easy *easyp;
86 struct Curl_easy *easylp; /* last node */
87
88 int num_easy; /* amount of entries in the linked list above. */
89 int num_alive; /* amount of easy handles that are added but have not yet
90 reached COMPLETE state */
91
92 struct curl_llist msglist; /* a list of messages from completed transfers */
93
94 struct curl_llist pending; /* Curl_easys that are in the
95 CURLM_STATE_CONNECT_PEND state */
96
97 /* callback function and user data pointer for the *socket() API */
98 curl_socket_callback socket_cb;
99 void *socket_userp;
100
101 /* callback function and user data pointer for server push */
102 curl_push_callback push_cb;
103 void *push_userp;
104
105 /* Hostname cache */
106 struct curl_hash hostcache;
107
108 #ifdef USE_LIBPSL
109 /* PSL cache. */
110 struct PslCache psl;
111 #endif
112
113 /* timetree points to the splay-tree of time nodes to figure out expire
114 times of all currently set timers */
115 struct Curl_tree *timetree;
116
117 /* 'sockhash' is the lookup hash for socket descriptor => easy handles (note
118 the pluralis form, there can be more than one easy handle waiting on the
119 same actual socket) */
120 struct curl_hash sockhash;
121
122 /* Shared connection cache (bundles)*/
123 struct conncache conn_cache;
124
125 long maxconnects; /* if >0, a fixed limit of the maximum number of entries
126 we're allowed to grow the connection cache to */
127
128 long max_host_connections; /* if >0, a fixed limit of the maximum number
129 of connections per host */
130
131 long max_total_connections; /* if >0, a fixed limit of the maximum number
132 of connections in total */
133
134 /* timer callback and user data pointer for the *socket() API */
135 curl_multi_timer_callback timer_cb;
136 void *timer_userp;
137 struct curltime timer_lastcall; /* the fixed time for the timeout for the
138 previous callback */
139 unsigned int max_concurrent_streams;
140
141 #ifdef ENABLE_WAKEUP
142 curl_socket_t wakeup_pair[2]; /* socketpair() used for wakeup
143 0 is used for read, 1 is used for write */
144 #endif
145 /* multiplexing wanted */
146 bool multiplexing;
147 bool recheckstate; /* see Curl_multi_connchanged */
148 bool in_callback; /* true while executing a callback */
149 bool ipv6_works;
150 };
151
152 #endif /* HEADER_CURL_MULTIHANDLE_H */