mirror of
https://github.com/curl/curl.git
synced 2026-04-19 15:31:14 +03:00
Use `data->progress.now` as the timestamp of proecssing a transfer. Update it on significant events and refrain from calling `curlx_now()` in many places. The problem this addresses is a) calling curlx_now() has costs, depending on platform. Calling it every time results in 25% increase `./runtest` duration on macOS. b) we used to pass a `struct curltime *` around to save on calls, but when some method directly use `curx_now()` and some use the passed pointer, the transfer experienes non-linear time. This results in timeline checks to report events in the wrong order. By keeping a timestamp in the easy handle and updating it there, no longer invoking `curlx_now()` in the "lower" methods, the transfer can observer a steady clock progression. Add documentation in docs/internals/TIME-KEEPING.md Reported-by: Viktor Szakats Fixes #19935 Closes #19961
82 lines
3.3 KiB
C
82 lines
3.3 KiB
C
#ifndef HEADER_CURL_MULTI_EV_H
|
|
#define HEADER_CURL_MULTI_EV_H
|
|
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
|
|
#include "hash.h"
|
|
|
|
struct Curl_easy;
|
|
struct Curl_multi;
|
|
struct easy_pollset;
|
|
struct uint32_bset;
|
|
|
|
/* meta key for event pollset at easy handle or connection */
|
|
#define CURL_META_MEV_POLLSET "meta:mev:ps"
|
|
|
|
struct curl_multi_ev {
|
|
struct Curl_hash sh_entries;
|
|
};
|
|
|
|
/* Setup/teardown of multi event book-keeping. */
|
|
void Curl_multi_ev_init(struct Curl_multi *multi, size_t hashsize);
|
|
void Curl_multi_ev_cleanup(struct Curl_multi *multi);
|
|
|
|
/* Assign a 'user_data' to be passed to the socket callback when
|
|
* invoked with the given socket. This will fail if this socket
|
|
* is not active, e.g. the application has not been told to monitor it. */
|
|
CURLMcode Curl_multi_ev_assign(struct Curl_multi *multi, curl_socket_t s,
|
|
void *user_data);
|
|
|
|
/* Assess the transfer by getting its current pollset, compute
|
|
* any changes to the last one and inform the application's socket
|
|
* callback if things have changed. */
|
|
CURLMcode Curl_multi_ev_assess_xfer(struct Curl_multi *multi,
|
|
struct Curl_easy *data);
|
|
/* Assess all easy handles on the list */
|
|
CURLMcode Curl_multi_ev_assess_xfer_bset(struct Curl_multi *multi,
|
|
struct uint32_bset *set,
|
|
struct curltime *pnow);
|
|
/* Assess the connection by getting its current pollset */
|
|
CURLMcode Curl_multi_ev_assess_conn(struct Curl_multi *multi,
|
|
struct Curl_easy *data,
|
|
struct connectdata *conn);
|
|
|
|
/* Mark all transfers tied to the given socket as dirty */
|
|
void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi,
|
|
curl_socket_t s);
|
|
|
|
/* Socket will be closed, forget anything we know about it. */
|
|
void Curl_multi_ev_socket_done(struct Curl_multi *multi,
|
|
struct Curl_easy *data, curl_socket_t s);
|
|
|
|
/* Transfer is removed from the multi */
|
|
void Curl_multi_ev_xfer_done(struct Curl_multi *multi,
|
|
struct Curl_easy *data);
|
|
|
|
/* Connection is being destroyed */
|
|
void Curl_multi_ev_conn_done(struct Curl_multi *multi,
|
|
struct Curl_easy *data,
|
|
struct connectdata *conn);
|
|
|
|
#endif /* HEADER_CURL_MULTI_EV_H */
|