diff options
author | Daniel Belz <dbelz760@yahoo.com> | 2021-12-17 11:45:57 -0800 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-12-18 17:04:38 +0100 |
commit | 4e6a9f287eadd77e0198a73d98db5c9fa149c7d1 (patch) | |
tree | 076209d0e5d032d79e134c730a189eea47bc90fe | |
parent | b29af4a406278c29d586d3c0f8b965681c114df7 (diff) | |
download | curl-bagder/tftp-timeout.tar.gz |
tftp: set timeout based on the connect-timeout parameterbagder/tftp-timeout
-rw-r--r-- | lib/tftp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/tftp.c b/lib/tftp.c index f8c68441c..240bf40e8 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -136,6 +136,7 @@ struct tftp_state_data { int rbytes; int sbytes; int blksize; + int option_timeout; int requested_blksize; unsigned short block; struct tftp_packet rpacket; @@ -222,6 +223,9 @@ static CURLcode tftp_set_timeouts(struct tftp_state_data *state) /* Set per-block timeout to total */ timeout = maxtime; + if(start) + state->option_timeout = (timeout > 255) ? 255 : (int)timeout; + /* Average reposting an ACK after 5 seconds */ state->retry_max = (int)timeout/5; @@ -507,7 +511,7 @@ static CURLcode tftp_send_first(struct tftp_state_data *state, (char *)state->spacket.data + sbytes, buf); /* add timeout option */ - msnprintf(buf, sizeof(buf), "%d", state->retry_time); + msnprintf(buf, sizeof(buf), "%d", state->option_timeout); if(result == CURLE_OK) result = tftp_option_add(state, &sbytes, (char *)state->spacket.data + sbytes, |