multiif.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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, <[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. * Prototypes for library-wide functions provided by multi.c
  28. */
  29. void Curl_expire(struct Curl_easy *data, timediff_t milli, expire_id);
  30. void Curl_expire_ex(struct Curl_easy *data,
  31. const struct curltime *nowp,
  32. timediff_t milli, expire_id id);
  33. bool Curl_expire_clear(struct Curl_easy *data);
  34. void Curl_expire_done(struct Curl_easy *data, expire_id id);
  35. CURLMcode Curl_update_timer(struct Curl_multi *multi) WARN_UNUSED_RESULT;
  36. void Curl_attach_connection(struct Curl_easy *data,
  37. struct connectdata *conn);
  38. void Curl_detach_connection(struct Curl_easy *data);
  39. bool Curl_multiplex_wanted(const struct Curl_multi *multi);
  40. void Curl_set_in_callback(struct Curl_easy *data, bool value);
  41. bool Curl_is_in_callback(struct Curl_easy *data);
  42. CURLcode Curl_preconnect(struct Curl_easy *data);
  43. void Curl_multi_connchanged(struct Curl_multi *multi);
  44. /* Internal version of curl_multi_init() accepts size parameters for the
  45. socket, connection and dns hashes */
  46. struct Curl_multi *Curl_multi_handle(unsigned int xfer_table_size,
  47. size_t hashsize,
  48. size_t chashsize,
  49. size_t dnssize,
  50. size_t sesssize);
  51. /**
  52. * Let the multi handle know that the socket is about to be closed.
  53. * The multi will then remove anything it knows about the socket, so
  54. * when the OS is using this socket (number) again subsequently,
  55. * the internal book keeping will not get confused.
  56. */
  57. void Curl_multi_will_close(struct Curl_easy *data, curl_socket_t s);
  58. /*
  59. * Add a handle and move it into PERFORM state at once. For pushed streams.
  60. */
  61. CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
  62. struct Curl_easy *data,
  63. struct connectdata *conn);
  64. /* Return the value of the CURLMOPT_MAX_CONCURRENT_STREAMS option */
  65. unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi);
  66. CURLMcode Curl_multi_pollset(struct Curl_easy *data,
  67. struct easy_pollset *ps,
  68. const char *caller);
  69. /**
  70. * Borrow the transfer buffer from the multi, suitable
  71. * for the given transfer `data`. The buffer may only be used in one
  72. * multi processing of the easy handle. It MUST be returned to the
  73. * multi before it can be borrowed again.
  74. * Pointers into the buffer remain only valid as long as it is borrowed.
  75. *
  76. * @param data the easy handle
  77. * @param pbuf on return, the buffer to use or NULL on error
  78. * @param pbuflen on return, the size of *pbuf or 0 on error
  79. * @return CURLE_OK when buffer is available and is returned.
  80. * CURLE_OUT_OF_MEMORy on failure to allocate the buffer,
  81. * CURLE_FAILED_INIT if the easy handle is without multi.
  82. * CURLE_AGAIN if the buffer is borrowed already.
  83. */
  84. CURLcode Curl_multi_xfer_buf_borrow(struct Curl_easy *data,
  85. char **pbuf, size_t *pbuflen);
  86. /**
  87. * Release the borrowed buffer. All references into the buffer become
  88. * invalid after this.
  89. * @param buf the buffer pointer borrowed for coding error checks.
  90. */
  91. void Curl_multi_xfer_buf_release(struct Curl_easy *data, char *buf);
  92. /**
  93. * Borrow the upload buffer from the multi, suitable
  94. * for the given transfer `data`. The buffer may only be used in one
  95. * multi processing of the easy handle. It MUST be returned to the
  96. * multi before it can be borrowed again.
  97. * Pointers into the buffer remain only valid as long as it is borrowed.
  98. *
  99. * @param data the easy handle
  100. * @param pbuf on return, the buffer to use or NULL on error
  101. * @param pbuflen on return, the size of *pbuf or 0 on error
  102. * @return CURLE_OK when buffer is available and is returned.
  103. * CURLE_OUT_OF_MEMORy on failure to allocate the buffer,
  104. * CURLE_FAILED_INIT if the easy handle is without multi.
  105. * CURLE_AGAIN if the buffer is borrowed already.
  106. */
  107. CURLcode Curl_multi_xfer_ulbuf_borrow(struct Curl_easy *data,
  108. char **pbuf, size_t *pbuflen);
  109. /**
  110. * Release the borrowed upload buffer. All references into the buffer become
  111. * invalid after this.
  112. * @param buf the upload buffer pointer borrowed for coding error checks.
  113. */
  114. void Curl_multi_xfer_ulbuf_release(struct Curl_easy *data, char *buf);
  115. /**
  116. * Borrow the socket scratch buffer from the multi, suitable
  117. * for the given transfer `data`. The buffer may only be used for
  118. * direct socket I/O operation by one connection at a time and MUST be
  119. * returned to the multi before the I/O call returns.
  120. * Pointers into the buffer remain only valid as long as it is borrowed.
  121. *
  122. * @param data the easy handle
  123. * @param blen requested length of the buffer
  124. * @param pbuf on return, the buffer to use or NULL on error
  125. * @return CURLE_OK when buffer is available and is returned.
  126. * CURLE_OUT_OF_MEMORy on failure to allocate the buffer,
  127. * CURLE_FAILED_INIT if the easy handle is without multi.
  128. * CURLE_AGAIN if the buffer is borrowed already.
  129. */
  130. CURLcode Curl_multi_xfer_sockbuf_borrow(struct Curl_easy *data,
  131. size_t blen, char **pbuf);
  132. /**
  133. * Release the borrowed buffer. All references into the buffer become
  134. * invalid after this.
  135. * @param buf the buffer pointer borrowed for coding error checks.
  136. */
  137. void Curl_multi_xfer_sockbuf_release(struct Curl_easy *data, char *buf);
  138. /**
  139. * Get the easy handle for the given mid.
  140. * Returns NULL if not found.
  141. */
  142. struct Curl_easy *Curl_multi_get_easy(struct Curl_multi *multi,
  143. unsigned int mid);
  144. /* Get the # of transfers current in process/pending. */
  145. unsigned int Curl_multi_xfers_running(struct Curl_multi *multi);
  146. /* Mark a transfer as dirty, e.g. to be rerun at earliest convenience.
  147. * A cheap operation, can be done many times repeatedly. */
  148. void Curl_multi_mark_dirty(struct Curl_easy *data);
  149. /* Clear transfer from the dirty set. */
  150. void Curl_multi_clear_dirty(struct Curl_easy *data);
  151. #endif /* HEADER_CURL_MULTIIF_H */