aboutsummaryrefslogtreecommitdiff
path: root/lib/tftp.c
diff options
context:
space:
mode:
authorMarcin Adamski <mass85@tlen.pl>2011-10-13 19:45:36 +0200
committerYang Tse <yangsita@gmail.com>2011-10-13 19:45:36 +0200
commit03adff1eba561c433a2667046c52d609322e684a (patch)
tree854a237b0cf48d6c343c738fa37a837888bc2bf9 /lib/tftp.c
parent34770b8ab0f2881b7437ef73ca757957335997a0 (diff)
tftp.c: TFTP timeout and unexpected block adjustments
Set ACK timeout to 5 seconds. If we are waiting for block X and receive block Y that is the expected one, we should send ACK and increase X (which is already implemented). Otherwise drop the packet and don't increase retry counter.
Diffstat (limited to 'lib/tftp.c')
-rw-r--r--lib/tftp.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/tftp.c b/lib/tftp.c
index ae1d5ebfe..8a85a1cdd 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -248,11 +248,11 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
state->max_time = state->start_time+maxtime;
- /* Set per-block timeout to 10% of total */
- timeout = maxtime/10 ;
+ /* Set per-block timeout to total */
+ timeout = maxtime;
- /* Average reposting an ACK after 15 seconds */
- state->retry_max = (int)timeout/15;
+ /* Average reposting an ACK after 5 seconds */
+ state->retry_max = (int)timeout/5;
}
/* But bound the total number */
if(state->retry_max<3)
@@ -591,15 +591,10 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
/* Is this the block we expect? */
rblock = getrpacketblock(&state->rpacket);
if(NEXT_BLOCKNUM(state->block) != rblock) {
- /* No, log it, up the retry count and fail if over the limit */
+ /* No, log it */
infof(data,
- "Received unexpected DATA packet block %d\n", rblock);
- state->retries++;
- if(state->retries > state->retry_max) {
- failf(data, "tftp_rx: giving up waiting for block %d",
- NEXT_BLOCKNUM(state->block));
- return CURLE_TFTP_ILLEGAL;
- }
+ "Received unexpected DATA packet block %d, expecting block %d\n",
+ rblock, NEXT_BLOCKNUM(state->block));
break;
}
/* This is the expected block. Reset counters and ACK it. */