Browse Source

[tftp] Remove unnecessary delay when opening a connection

The retry timer is used to retransmit TFTP packets lost on the network,
and to start a new connection.  There is an unnecessary delay while
waiting for name resolution because the timer period is fixed and cannot
be shortened when name resolution completes.  This patch keeps the timer
period at zero while name resolution takes place so that no time is lost
once before sending the first packet.

Reported-by: Thomas Horsten <thomas@horsten.com>
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.0.0-rc1
Stefan Hajnoczi 14 years ago
parent
commit
245dca9ce6
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      src/net/udp/tftp.c

+ 9
- 2
src/net/udp/tftp.c View File

418
  */
418
  */
419
 static int tftp_send_packet ( struct tftp_request *tftp ) {
419
 static int tftp_send_packet ( struct tftp_request *tftp ) {
420
 
420
 
421
-	/* Update retransmission timer */
421
+	/* Update retransmission timer.  While name resolution takes place the
422
+	 * window is zero.  Avoid unnecessary delay after name resolution
423
+	 * completes by retrying immediately.
424
+	 */
422
 	stop_timer ( &tftp->timer );
425
 	stop_timer ( &tftp->timer );
423
-	start_timer ( &tftp->timer );
426
+	if ( xfer_window ( &tftp->socket ) ) {
427
+		start_timer ( &tftp->timer );
428
+	} else {
429
+		start_timer_nodelay ( &tftp->timer );
430
+	}
424
 
431
 
425
 	/* Send RRQ or ACK as appropriate */
432
 	/* Send RRQ or ACK as appropriate */
426
 	if ( ! tftp->peer.st_family ) {
433
 	if ( ! tftp->peer.st_family ) {

Loading…
Cancel
Save