Debian Codegraph @

extra/curl/curl-8.14.1/lib/multihandle.h

raw symbols SCIP
1 #ifndef HEADER_CURL_MULTIHANDLE_H
2 #define HEADER_CURL_MULTIHANDLE_H
3 /***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) 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.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 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26
27 #include "llist.h"
28 #include "hash.h"
29 #include "conncache.h"
30 #include "cshutdn.h"
31 #include "hostip.h"
32 #include "multi_ev.h"
33 #include "psl.h"
34 #include "socketpair.h"
35 #include "uint-bset.h"
36 #include "uint-spbset.h"
37 #include "uint-table.h"
38
39 struct connectdata;
40 struct Curl_easy;
41
42 struct Curl_message {
43 struct Curl_llist_node list;
44 /* the 'CURLMsg' is the part that is visible to the external user */
45 struct CURLMsg extmsg;
46 };
47
48 /* NOTE: if you add a state here, add the name to the statenames[] array
49 * in curl_trc.c as well!
50 */
51 typedef enum {
52 MSTATE_INIT, /* 0 - start in this state */
53 MSTATE_PENDING, /* 1 - no connections, waiting for one */
54 MSTATE_SETUP, /* 2 - start a new transfer */
55 MSTATE_CONNECT, /* 3 - resolve/connect has been sent off */
56 MSTATE_RESOLVING, /* 4 - awaiting the resolve to finalize */
57 MSTATE_CONNECTING, /* 5 - awaiting the TCP connect to finalize */
58 MSTATE_TUNNELING, /* 6 - awaiting HTTPS proxy SSL initialization to
59 complete and/or proxy CONNECT to finalize */
60 MSTATE_PROTOCONNECT, /* 7 - initiate protocol connect procedure */
61 MSTATE_PROTOCONNECTING, /* 8 - completing the protocol-specific connect
62 phase */
63 MSTATE_DO, /* 9 - start send off the request (part 1) */
64 MSTATE_DOING, /* 10 - sending off the request (part 1) */
65 MSTATE_DOING_MORE, /* 11 - send off the request (part 2) */
66 MSTATE_DID, /* 12 - done sending off request */
67 MSTATE_PERFORMING, /* 13 - transfer data */
68 MSTATE_RATELIMITING, /* 14 - wait because limit-rate exceeded */
69 MSTATE_DONE, /* 15 - post data transfer operation */
70 MSTATE_COMPLETED, /* 16 - operation complete */
71 MSTATE_MSGSENT, /* 17 - the operation complete message is sent */
72 MSTATE_LAST /* 18 - not a true state, never use this */
73 } CURLMstate;
74
75 /* we support N sockets per easy handle. Set the corresponding bit to what
76 action we should wait for */
77 #define MAX_SOCKSPEREASYHANDLE 5
78 #define GETSOCK_READABLE (0x00ff)
79 #define GETSOCK_WRITABLE (0xff00)
80
81 #define CURLPIPE_ANY (CURLPIPE_MULTIPLEX)
82
83 #if !defined(CURL_DISABLE_SOCKETPAIR)
84 #define ENABLE_WAKEUP
85 #endif
86
87 /* value for MAXIMUM CONCURRENT STREAMS upper limit */
88 #define INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1)
89
90 /* This is the struct known as CURLM on the outside */
91 struct Curl_multi {
92 /* First a simple identifier to easier detect if a user mix up
93 this multi handle with an easy handle. Set this to CURL_MULTI_HANDLE. */
94 unsigned int magic;
95
96 unsigned int xfers_alive; /* amount of added transfers that have
97 not yet reached COMPLETE state */
98 struct uint_tbl xfers; /* transfers added to this multi */
99 /* Each transfer's mid may be present in at most one of these */
100 struct uint_bset process; /* transfer being processed */
101 struct uint_bset pending; /* transfers in waiting (conn limit etc.) */
102 struct uint_bset msgsent; /* transfers done with message for application */
103
104 struct Curl_llist msglist; /* a list of messages from completed transfers */
105
106 struct Curl_easy *admin; /* internal easy handle for admin operations.
107 gets assigned `mid` 0 on multi init */
108
109 /* callback function and user data pointer for the *socket() API */
110 curl_socket_callback socket_cb;
111 void *socket_userp;
112
113 /* callback function and user data pointer for server push */
114 curl_push_callback push_cb;
115 void *push_userp;
116
117 struct Curl_dnscache dnscache; /* DNS cache */
118 struct Curl_ssl_scache *ssl_scache; /* TLS session pool */
119
120 #ifdef USE_LIBPSL
121 /* PSL cache. */
122 struct PslCache psl;
123 #endif
124
125 /* timetree points to the splay-tree of time nodes to figure out expire
126 times of all currently set timers */
127 struct Curl_tree *timetree;
128
129 /* buffer used for transfer data, lazy initialized */
130 char *xfer_buf; /* the actual buffer */
131 size_t xfer_buf_len; /* the allocated length */
132 /* buffer used for upload data, lazy initialized */
133 char *xfer_ulbuf; /* the actual buffer */
134 size_t xfer_ulbuf_len; /* the allocated length */
135 /* buffer used for socket I/O operations, lazy initialized */
136 char *xfer_sockbuf; /* the actual buffer */
137 size_t xfer_sockbuf_len; /* the allocated length */
138
139 /* multi event related things */
140 struct curl_multi_ev ev;
141
142 /* `proto_hash` is a general key-value store for protocol implementations
143 * with the lifetime of the multi handle. The number of elements kept here
144 * should be in the order of supported protocols (and sub-protocols like
145 * TLS), *not* in the order of connections or current transfers!
146 * Elements need to be added with their own destructor to be invoked when
147 * the multi handle is cleaned up (see Curl_hash_add2()).*/
148 struct Curl_hash proto_hash;
149
150 struct cshutdn cshutdn; /* connection shutdown handling */
151 struct cpool cpool; /* connection pool (bundles) */
152
153 long max_host_connections; /* if >0, a fixed limit of the maximum number
154 of connections per host */
155
156 long max_total_connections; /* if >0, a fixed limit of the maximum number
157 of connections in total */
158
159 /* timer callback and user data pointer for the *socket() API */
160 curl_multi_timer_callback timer_cb;
161 void *timer_userp;
162 long last_timeout_ms; /* the last timeout value set via timer_cb */
163 struct curltime last_expire_ts; /* timestamp of last expiry */
164
165 #ifdef USE_WINSOCK
166 WSAEVENT wsa_event; /* Winsock event used for waits */
167 #else
168 #ifdef ENABLE_WAKEUP
169 curl_socket_t wakeup_pair[2]; /* eventfd()/pipe()/socketpair() used for
170 wakeup 0 is used for read, 1 is used
171 for write */
172 #endif
173 #endif
174 unsigned int max_concurrent_streams;
175 unsigned int maxconnects; /* if >0, a fixed limit of the maximum number of
176 entries we are allowed to grow the connection
177 cache to */
178 #define IPV6_UNKNOWN 0
179 #define IPV6_DEAD 1
180 #define IPV6_WORKS 2
181 unsigned char ipv6_up; /* IPV6_* defined */
182 BIT(multiplexing); /* multiplexing wanted */
183 BIT(recheckstate); /* see Curl_multi_connchanged */
184 BIT(in_callback); /* true while executing a callback */
185 #ifdef USE_OPENSSL
186 BIT(ssl_seeded);
187 #endif
188 BIT(dead); /* a callback returned error, everything needs to crash and
189 burn */
190 BIT(xfer_buf_borrowed); /* xfer_buf is currently being borrowed */
191 BIT(xfer_ulbuf_borrowed); /* xfer_ulbuf is currently being borrowed */
192 BIT(xfer_sockbuf_borrowed); /* xfer_sockbuf is currently being borrowed */
193 #ifdef DEBUGBUILD
194 BIT(warned); /* true after user warned of DEBUGBUILD */
195 #endif
196 };
197
198 #endif /* HEADER_CURL_MULTIHANDLE_H */