Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Curl_timeleft: change return type to timediff_t #2021

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/asyn-ares.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
long timeout;
timediff_t timeout;
struct curltime now = Curl_now();
struct Curl_dns_entry *temp_entry;

Expand Down
10 changes: 5 additions & 5 deletions lib/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ singleipconnect(struct connectdata *conn,
*
* @unittest: 1303
*/
time_t Curl_timeleft(struct Curl_easy *data,
struct curltime *nowp,
bool duringconnect)
timediff_t Curl_timeleft(struct Curl_easy *data,
struct curltime *nowp,
bool duringconnect)
{
int timeout_set = 0;
time_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
timediff_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
struct curltime now;

/* if a timeout is set, use the most restrictive one */
Expand Down Expand Up @@ -1148,7 +1148,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
struct curltime before = Curl_now();
CURLcode result = CURLE_COULDNT_CONNECT;

time_t timeout_ms = Curl_timeleft(data, &before, TRUE);
timediff_t timeout_ms = Curl_timeleft(data, &before, TRUE);

if(timeout_ms < 0) {
/* a precaution, no need to continue if time already is up */
Expand Down
7 changes: 4 additions & 3 deletions lib/connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
#include "sockaddr.h"
#include "timeval.h"

CURLcode Curl_is_connected(struct connectdata *conn,
int sockindex,
Expand All @@ -35,9 +36,9 @@ CURLcode Curl_connecthost(struct connectdata *conn,

/* generic function that returns how much time there's left to run, according
to the timeouts set */
time_t Curl_timeleft(struct Curl_easy *data,
struct curltime *nowp,
bool duringconnect);
timediff_t Curl_timeleft(struct Curl_easy *data,
struct curltime *nowp,
bool duringconnect);

#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
#define HAPPY_EYEBALLS_TIMEOUT 200 /* milliseconds to wait between
Expand Down
6 changes: 3 additions & 3 deletions lib/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
* Curl_pgrsTime(..., TIMER_STARTACCEPT);
*
*/
static time_t ftp_timeleft_accept(struct Curl_easy *data)
static timediff_t ftp_timeleft_accept(struct Curl_easy *data)
{
time_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
time_t other;
timediff_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
timediff_t other;
struct curltime now;

if(data->set.accepttimeout > 0)
Expand Down
2 changes: 1 addition & 1 deletion lib/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
struct SingleRequest *k;
time_t timeout_ms;
time_t recv_timeout_ms;
time_t send_timeout_ms;
timediff_t send_timeout_ms;
int control;

if(!GOOD_EASY_HANDLE(data))
Expand Down
4 changes: 2 additions & 2 deletions lib/socks.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
ssize_t nread;
ssize_t allread = 0;
int result;
time_t timeleft;
timediff_t timeleft;
*n = 0;
for(;;) {
timeleft = Curl_timeleft(conn->data, NULL, TRUE);
Expand Down Expand Up @@ -382,7 +382,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
CURLcode code;
curl_socket_t sock = conn->sock[sockindex];
struct Curl_easy *data = conn->data;
time_t timeout;
timediff_t timeout;
bool socks5_resolve_local =
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
const size_t hostname_len = strlen(hostname);
Expand Down
2 changes: 1 addition & 1 deletion lib/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -2833,7 +2833,7 @@ static CURLcode ssh_block_statemach(struct connectdata *conn,

while((sshc->state != SSH_STOP) && !result) {
bool block;
time_t left = 1000;
timediff_t left = 1000;
struct curltime now = Curl_now();

result = ssh_statemach_act(conn, &block);
Expand Down
2 changes: 1 addition & 1 deletion lib/tftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const struct Curl_handler Curl_handler_tftp = {
static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
{
time_t maxtime, timeout;
time_t timeout_ms;
timediff_t timeout_ms;
bool start = (state->state == TFTP_STATE_START) ? TRUE : FALSE;

time(&state->start_time);
Expand Down
2 changes: 1 addition & 1 deletion lib/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -6323,7 +6323,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
bool *async)
{
CURLcode result = CURLE_OK;
time_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);

/*************************************************************
* Resolve the name of the server or proxy
Expand Down