diff options
author | Daniel Stenberg <daniel@haxx.se> | 2008-02-07 22:25:04 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2008-02-07 22:25:04 +0000 |
commit | 1b701c746f66b8fd5bf3017c36254dbde8456df2 (patch) | |
tree | 9ce8d20c20100c4fb9bbec0966928641f9f910b7 /lib/tftp.c | |
parent | 15bf16852705a585b694cb0d50d21f7edd6b7a88 (diff) |
- Refactored a lot of timeout code into a few functions in an attempt to make
them all use the same (hopefully correct) logic to make it less error-prone
and easier to introduce library-wide where it should be used.
Diffstat (limited to 'lib/tftp.c')
-rw-r--r-- | lib/tftp.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/tftp.c b/lib/tftp.c index 94e5fc3fe..3f7d6442c 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -114,7 +114,7 @@ typedef enum { TFTP_ERR_ILLEGAL, TFTP_ERR_UNKNOWNID, TFTP_ERR_EXISTS, - TFTP_ERR_NOSUCHUSER, /* This will never be triggered by this code */ + TFTP_ERR_NOSUCHUSER, /* This will never be triggered by this code */ /* The remaining error codes are internal to curl */ TFTP_ERR_NONE = -100, @@ -194,12 +194,14 @@ static void tftp_set_timeouts(tftp_state_data_t *state) struct SessionHandle *data = state->conn->data; time_t maxtime, timeout; + long timeout_ms; time(&state->start_time); + if(state->state == TFTP_STATE_START) { /* Compute drop-dead time */ - maxtime = (time_t)(data->set.connecttimeout/1000L? - data->set.connecttimeout/1000L:30); + timeout_ms = Curl_timeleft(state->conn, NULL, TRUE); + maxtime = (time_t)(timeout_ms + 500) / 1000; state->max_time = state->start_time+maxtime; /* Set per-block timeout to total */ @@ -219,10 +221,13 @@ static void tftp_set_timeouts(tftp_state_data_t *state) } else { - /* Compute drop-dead time */ - maxtime = (time_t)(data->set.timeout/1000L? - data->set.timeout/1000L:3600); + timeout_ms = Curl_timeleft(state->conn, NULL, TRUE); + if(timeout_ms > 0) + maxtime = (time_t)(timeout_ms + 500) / 1000; + else + maxtime = 3600; + state->max_time = state->start_time+maxtime; /* Set per-block timeout to 10% of total */ |