00001 #ifndef HEADER_CURL_MULTIHANDLE_H 00002 #define HEADER_CURL_MULTIHANDLE_H 00003 /*************************************************************************** 00004 * _ _ ____ _ 00005 * Project ___| | | | _ \| | 00006 * / __| | | | |_) | | 00007 * | (__| |_| | _ <| |___ 00008 * \___|\___/|_| \_\_____| 00009 * 00010 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. 00011 * 00012 * This software is licensed as described in the file COPYING, which 00013 * you should have received as part of this distribution. The terms 00014 * are also available at https://curl.haxx.se/docs/copyright.html. 00015 * 00016 * You may opt to use, copy, modify, merge, publish, distribute and/or sell 00017 * copies of the Software, and permit persons to whom the Software is 00018 * furnished to do so, under the terms of the COPYING file. 00019 * 00020 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 00021 * KIND, either express or implied. 00022 * 00023 ***************************************************************************/ 00024 00025 #include "conncache.h" 00026 00027 struct Curl_message { 00028 /* the 'CURLMsg' is the part that is visible to the external user */ 00029 struct CURLMsg extmsg; 00030 }; 00031 00032 /* NOTE: if you add a state here, add the name to the statename[] array as 00033 well! 00034 */ 00035 typedef enum { 00036 CURLM_STATE_INIT, /* 0 - start in this state */ 00037 CURLM_STATE_CONNECT_PEND, /* 1 - no connections, waiting for one */ 00038 CURLM_STATE_CONNECT, /* 2 - resolve/connect has been sent off */ 00039 CURLM_STATE_WAITRESOLVE, /* 3 - awaiting the resolve to finalize */ 00040 CURLM_STATE_WAITCONNECT, /* 4 - awaiting the TCP connect to finalize */ 00041 CURLM_STATE_WAITPROXYCONNECT, /* 5 - awaiting HTTPS proxy SSL initialization 00042 to complete and/or proxy CONNECT to 00043 finalize */ 00044 CURLM_STATE_SENDPROTOCONNECT, /* 6 - initiate protocol connect procedure */ 00045 CURLM_STATE_PROTOCONNECT, /* 7 - completing the protocol-specific connect 00046 phase */ 00047 CURLM_STATE_WAITDO, /* 8 - wait for our turn to send the request */ 00048 CURLM_STATE_DO, /* 9 - start send off the request (part 1) */ 00049 CURLM_STATE_DOING, /* 10 - sending off the request (part 1) */ 00050 CURLM_STATE_DO_MORE, /* 11 - send off the request (part 2) */ 00051 CURLM_STATE_DO_DONE, /* 12 - done sending off request */ 00052 CURLM_STATE_WAITPERFORM, /* 13 - wait for our turn to read the response */ 00053 CURLM_STATE_PERFORM, /* 14 - transfer data */ 00054 CURLM_STATE_TOOFAST, /* 15 - wait because limit-rate exceeded */ 00055 CURLM_STATE_DONE, /* 16 - post data transfer operation */ 00056 CURLM_STATE_COMPLETED, /* 17 - operation complete */ 00057 CURLM_STATE_MSGSENT, /* 18 - the operation complete message is sent */ 00058 CURLM_STATE_LAST /* 19 - not a true state, never use this */ 00059 } CURLMstate; 00060 00061 /* we support N sockets per easy handle. Set the corresponding bit to what 00062 action we should wait for */ 00063 #define MAX_SOCKSPEREASYHANDLE 5 00064 #define GETSOCK_READABLE (0x00ff) 00065 #define GETSOCK_WRITABLE (0xff00) 00066 00067 #define CURLPIPE_ANY (CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX) 00068 00069 /* This is the struct known as CURLM on the outside */ 00070 struct Curl_multi { 00071 /* First a simple identifier to easier detect if a user mix up 00072 this multi handle with an easy handle. Set this to CURL_MULTI_HANDLE. */ 00073 long type; 00074 00075 /* We have a doubly-linked circular list with easy handles */ 00076 struct Curl_easy *easyp; 00077 struct Curl_easy *easylp; /* last node */ 00078 00079 int num_easy; /* amount of entries in the linked list above. */ 00080 int num_alive; /* amount of easy handles that are added but have not yet 00081 reached COMPLETE state */ 00082 00083 struct curl_llist *msglist; /* a list of messages from completed transfers */ 00084 00085 struct curl_llist *pending; /* Curl_easys that are in the 00086 CURLM_STATE_CONNECT_PEND state */ 00087 00088 /* callback function and user data pointer for the *socket() API */ 00089 curl_socket_callback socket_cb; 00090 void *socket_userp; 00091 00092 /* callback function and user data pointer for server push */ 00093 curl_push_callback push_cb; 00094 void *push_userp; 00095 00096 /* Hostname cache */ 00097 struct curl_hash hostcache; 00098 00099 /* timetree points to the splay-tree of time nodes to figure out expire 00100 times of all currently set timers */ 00101 struct Curl_tree *timetree; 00102 00103 /* 'sockhash' is the lookup hash for socket descriptor => easy handles (note 00104 the pluralis form, there can be more than one easy handle waiting on the 00105 same actual socket) */ 00106 struct curl_hash sockhash; 00107 00108 /* pipelining wanted bits (CURLPIPE*) */ 00109 long pipelining; 00110 00111 bool recheckstate; /* see Curl_multi_connchanged */ 00112 00113 /* Shared connection cache (bundles)*/ 00114 struct conncache conn_cache; 00115 00116 /* This handle will be used for closing the cached connections in 00117 curl_multi_cleanup() */ 00118 struct Curl_easy *closure_handle; 00119 00120 long maxconnects; /* if >0, a fixed limit of the maximum number of entries 00121 we're allowed to grow the connection cache to */ 00122 00123 long max_host_connections; /* if >0, a fixed limit of the maximum number 00124 of connections per host */ 00125 00126 long max_total_connections; /* if >0, a fixed limit of the maximum number 00127 of connections in total */ 00128 00129 long max_pipeline_length; /* if >0, maximum number of requests in a 00130 pipeline */ 00131 00132 long content_length_penalty_size; /* a connection with a 00133 content-length bigger than 00134 this is not considered 00135 for pipelining */ 00136 00137 long chunk_length_penalty_size; /* a connection with a chunk length 00138 bigger than this is not 00139 considered for pipelining */ 00140 00141 struct curl_llist *pipelining_site_bl; /* List of sites that are blacklisted 00142 from pipelining */ 00143 00144 struct curl_llist *pipelining_server_bl; /* List of server types that are 00145 blacklisted from pipelining */ 00146 00147 /* timer callback and user data pointer for the *socket() API */ 00148 curl_multi_timer_callback timer_cb; 00149 void *timer_userp; 00150 struct timeval timer_lastcall; /* the fixed time for the timeout for the 00151 previous callback */ 00152 }; 00153 00154 #endif /* HEADER_CURL_MULTIHANDLE_H */