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