multihandle.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef HEADER_CURL_MULTIHANDLE_H
  2. #define HEADER_CURL_MULTIHANDLE_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2014, 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
  14. * are also available at http://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. struct Curl_message {
  25. /* the 'CURLMsg' is the part that is visible to the external user */
  26. struct CURLMsg extmsg;
  27. };
  28. /* NOTE: if you add a state here, add the name to the statename[] array as
  29. well!
  30. */
  31. typedef enum {
  32. CURLM_STATE_INIT, /* 0 - start in this state */
  33. CURLM_STATE_CONNECT_PEND, /* 1 - no connections, waiting for one */
  34. CURLM_STATE_CONNECT, /* 2 - resolve/connect has been sent off */
  35. CURLM_STATE_WAITRESOLVE, /* 3 - awaiting the resolve to finalize */
  36. CURLM_STATE_WAITCONNECT, /* 4 - awaiting the connect to finalize */
  37. CURLM_STATE_WAITPROXYCONNECT, /* 5 - awaiting proxy CONNECT to finalize */
  38. CURLM_STATE_PROTOCONNECT, /* 6 - completing the protocol-specific connect
  39. phase */
  40. CURLM_STATE_WAITDO, /* 7 - wait for our turn to send the request */
  41. CURLM_STATE_DO, /* 8 - start send off the request (part 1) */
  42. CURLM_STATE_DOING, /* 9 - sending off the request (part 1) */
  43. CURLM_STATE_DO_MORE, /* 10 - send off the request (part 2) */
  44. CURLM_STATE_DO_DONE, /* 11 - done sending off request */
  45. CURLM_STATE_WAITPERFORM, /* 12 - wait for our turn to read the response */
  46. CURLM_STATE_PERFORM, /* 13 - transfer data */
  47. CURLM_STATE_TOOFAST, /* 14 - wait because limit-rate exceeded */
  48. CURLM_STATE_DONE, /* 15 - post data transfer operation */
  49. CURLM_STATE_COMPLETED, /* 16 - operation complete */
  50. CURLM_STATE_MSGSENT, /* 17 - the operation complete message is sent */
  51. CURLM_STATE_LAST /* 18 - not a true state, never use this */
  52. } CURLMstate;
  53. /* we support N sockets per easy handle. Set the corresponding bit to what
  54. action we should wait for */
  55. #define MAX_SOCKSPEREASYHANDLE 5
  56. #define GETSOCK_READABLE (0x00ff)
  57. #define GETSOCK_WRITABLE (0xff00)
  58. /* This is the struct known as CURLM on the outside */
  59. struct Curl_multi {
  60. /* First a simple identifier to easier detect if a user mix up
  61. this multi handle with an easy handle. Set this to CURL_MULTI_HANDLE. */
  62. long type;
  63. /* We have a doubly-linked circular list with easy handles */
  64. struct SessionHandle *easyp;
  65. struct SessionHandle *easylp; /* last node */
  66. int num_easy; /* amount of entries in the linked list above. */
  67. int num_alive; /* amount of easy handles that are added but have not yet
  68. reached COMPLETE state */
  69. struct curl_llist *msglist; /* a list of messages from completed transfers */
  70. struct curl_llist *pending; /* SessionHandles that are in the
  71. CURLM_STATE_CONNECT_PEND state */
  72. /* callback function and user data pointer for the *socket() API */
  73. curl_socket_callback socket_cb;
  74. void *socket_userp;
  75. /* Hostname cache */
  76. struct curl_hash *hostcache;
  77. /* timetree points to the splay-tree of time nodes to figure out expire
  78. times of all currently set timers */
  79. struct Curl_tree *timetree;
  80. /* 'sockhash' is the lookup hash for socket descriptor => easy handles (note
  81. the pluralis form, there can be more than one easy handle waiting on the
  82. same actual socket) */
  83. struct curl_hash *sockhash;
  84. /* Whether pipelining is enabled for this multi handle */
  85. bool pipelining_enabled;
  86. /* Shared connection cache (bundles)*/
  87. struct conncache *conn_cache;
  88. /* This handle will be used for closing the cached connections in
  89. curl_multi_cleanup() */
  90. struct SessionHandle *closure_handle;
  91. long maxconnects; /* if >0, a fixed limit of the maximum number of entries
  92. we're allowed to grow the connection cache to */
  93. long max_host_connections; /* if >0, a fixed limit of the maximum number
  94. of connections per host */
  95. long max_total_connections; /* if >0, a fixed limit of the maximum number
  96. of connections in total */
  97. long max_pipeline_length; /* if >0, maximum number of requests in a
  98. pipeline */
  99. long content_length_penalty_size; /* a connection with a
  100. content-length bigger than
  101. this is not considered
  102. for pipelining */
  103. long chunk_length_penalty_size; /* a connection with a chunk length
  104. bigger than this is not
  105. considered for pipelining */
  106. struct curl_llist *pipelining_site_bl; /* List of sites that are blacklisted
  107. from pipelining */
  108. struct curl_llist *pipelining_server_bl; /* List of server types that are
  109. blacklisted from pipelining */
  110. /* timer callback and user data pointer for the *socket() API */
  111. curl_multi_timer_callback timer_cb;
  112. void *timer_userp;
  113. struct timeval timer_lastcall; /* the fixed time for the timeout for the
  114. previous callback */
  115. };
  116. #endif /* HEADER_CURL_MULTIHANDLE_H */