2
0

multiif.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #ifndef HEADER_CURL_MULTIIF_H
  2. #define HEADER_CURL_MULTIIF_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 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 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. * Prototypes for library-wide functions provided by multi.c
  28. */
  29. CURLcode Curl_updatesocket(struct Curl_easy *data);
  30. void Curl_expire(struct Curl_easy *data, timediff_t milli, expire_id);
  31. bool Curl_expire_clear(struct Curl_easy *data);
  32. void Curl_expire_done(struct Curl_easy *data, expire_id id);
  33. CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT;
  34. void Curl_attach_connection(struct Curl_easy *data,
  35. struct connectdata *conn);
  36. void Curl_detach_connection(struct Curl_easy *data);
  37. bool Curl_multiplex_wanted(const struct Curl_multi *multi);
  38. void Curl_set_in_callback(struct Curl_easy *data, bool value);
  39. bool Curl_is_in_callback(struct Curl_easy *data);
  40. CURLcode Curl_preconnect(struct Curl_easy *data);
  41. void Curl_multi_connchanged(struct Curl_multi *multi);
  42. /* Internal version of curl_multi_init() accepts size parameters for the
  43. socket, connection and dns hashes */
  44. struct Curl_multi *Curl_multi_handle(size_t hashsize,
  45. size_t chashsize,
  46. size_t dnssize);
  47. /* the write bits start at bit 16 for the *getsock() bitmap */
  48. #define GETSOCK_WRITEBITSTART 16
  49. #define GETSOCK_BLANK 0 /* no bits set */
  50. /* set the bit for the given sock number to make the bitmap for writable */
  51. #define GETSOCK_WRITESOCK(x) (1 << (GETSOCK_WRITEBITSTART + (x)))
  52. /* set the bit for the given sock number to make the bitmap for readable */
  53. #define GETSOCK_READSOCK(x) (1 << (x))
  54. /* mask for checking if read and/or write is set for index x */
  55. #define GETSOCK_MASK_RW(x) (GETSOCK_READSOCK(x)|GETSOCK_WRITESOCK(x))
  56. /*
  57. * Curl_multi_closed()
  58. *
  59. * Used by the connect code to tell the multi_socket code that one of the
  60. * sockets we were using is about to be closed. This function will then
  61. * remove it from the sockethash for this handle to make the multi_socket API
  62. * behave properly, especially for the case when libcurl will create another
  63. * socket again and it gets the same file descriptor number.
  64. */
  65. void Curl_multi_closed(struct Curl_easy *data, curl_socket_t s);
  66. /* Compare the two pollsets to notify the multi_socket API of changes
  67. * in socket polling, e.g calling multi->socket_cb() with the changes if
  68. * differences are seen.
  69. */
  70. CURLMcode Curl_multi_pollset_ev(struct Curl_multi *multi,
  71. struct Curl_easy *data,
  72. struct easy_pollset *ps,
  73. struct easy_pollset *last_ps);
  74. /*
  75. * Add a handle and move it into PERFORM state at once. For pushed streams.
  76. */
  77. CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
  78. struct Curl_easy *data,
  79. struct connectdata *conn);
  80. /* Return the value of the CURLMOPT_MAX_CONCURRENT_STREAMS option */
  81. unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi);
  82. /**
  83. * Borrow the transfer buffer from the multi, suitable
  84. * for the given transfer `data`. The buffer may only be used in one
  85. * multi processing of the easy handle. It MUST be returned to the
  86. * multi before it can be borrowed again.
  87. * Pointers into the buffer remain only valid as long as it is borrowed.
  88. *
  89. * @param data the easy handle
  90. * @param pbuf on return, the buffer to use or NULL on error
  91. * @param pbuflen on return, the size of *pbuf or 0 on error
  92. * @return CURLE_OK when buffer is available and is returned.
  93. * CURLE_OUT_OF_MEMORy on failure to allocate the buffer,
  94. * CURLE_FAILED_INIT if the easy handle is without multi.
  95. * CURLE_AGAIN if the buffer is borrowed already.
  96. */
  97. CURLcode Curl_multi_xfer_buf_borrow(struct Curl_easy *data,
  98. char **pbuf, size_t *pbuflen);
  99. /**
  100. * Release the borrowed buffer. All references into the buffer become
  101. * invalid after this.
  102. * @param buf the buffer pointer borrowed for coding error checks.
  103. */
  104. void Curl_multi_xfer_buf_release(struct Curl_easy *data, char *buf);
  105. /**
  106. * Borrow the upload buffer from the multi, suitable
  107. * for the given transfer `data`. The buffer may only be used in one
  108. * multi processing of the easy handle. It MUST be returned to the
  109. * multi before it can be borrowed again.
  110. * Pointers into the buffer remain only valid as long as it is borrowed.
  111. *
  112. * @param data the easy handle
  113. * @param pbuf on return, the buffer to use or NULL on error
  114. * @param pbuflen on return, the size of *pbuf or 0 on error
  115. * @return CURLE_OK when buffer is available and is returned.
  116. * CURLE_OUT_OF_MEMORy on failure to allocate the buffer,
  117. * CURLE_FAILED_INIT if the easy handle is without multi.
  118. * CURLE_AGAIN if the buffer is borrowed already.
  119. */
  120. CURLcode Curl_multi_xfer_ulbuf_borrow(struct Curl_easy *data,
  121. char **pbuf, size_t *pbuflen);
  122. /**
  123. * Release the borrowed upload buffer. All references into the buffer become
  124. * invalid after this.
  125. * @param buf the upload buffer pointer borrowed for coding error checks.
  126. */
  127. void Curl_multi_xfer_ulbuf_release(struct Curl_easy *data, char *buf);
  128. /**
  129. * Get the transfer handle for the given id. Returns NULL if not found.
  130. */
  131. struct Curl_easy *Curl_multi_get_handle(struct Curl_multi *multi,
  132. curl_off_t id);
  133. #endif /* HEADER_CURL_MULTIIF_H */