From: Wolfram Sang <w.sang@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 5/6] net: tftp: do not retry endlessly
Date: Wed, 4 Apr 2012 18:04:43 +0200 [thread overview]
Message-ID: <1333555484-32635-6-git-send-email-w.sang@pengutronix.de> (raw)
In-Reply-To: <1333555484-32635-1-git-send-email-w.sang@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
net/tftp.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/net/tftp.c b/net/tftp.c
index 243ad0a..fc33c94 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -39,6 +39,7 @@ static unsigned int tftp_last_block; /* last packet sequence number received */
static int tftp_state;
static uint64_t tftp_timer_start;
static int tftp_err;
+static unsigned tftp_retries;
#define STATE_RRQ 1
#define STATE_WRQ 2
@@ -106,6 +107,7 @@ static int tftp_send(void)
}
tftp_last_block = tftp_block;
+ tftp_retries = 0;
s = (uint16_t *)pkt;
*s++ = htons(TFTP_DATA);
*s++ = htons(tftp_block);
@@ -231,6 +233,7 @@ static void tftp_handler(void *ctx, char *packet, unsigned len)
break;
tftp_last_block = tftp_block;
+ tftp_retries = 0;
if (!(tftp_block % 10))
tftp_size++;
@@ -278,6 +281,7 @@ static int do_tftpb(int argc, char *argv[])
do_tftp_push(0);
tftp_last_block = 0;
tftp_size = 0;
+ tftp_retries = 0;
while((opt = getopt(argc, argv, "p")) > 0) {
switch(opt) {
@@ -348,6 +352,12 @@ static int do_tftpb(int argc, char *argv[])
tftp_err = tftp_send();
if (tftp_err)
goto out_unreg;
+ tftp_retries++;
+ }
+
+ if (tftp_retries > PKT_NUM_RETRIES) {
+ tftp_err = -ETIMEDOUT;
+ break;
}
}
out_unreg:
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-04-04 16:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-04 16:04 [PATCH 0/6] net: minor cleanups & avoid endless retries Wolfram Sang
2012-04-04 16:04 ` [PATCH 1/6] net: ping: send PING packets with 1-second interval Wolfram Sang
2012-04-04 16:04 ` [PATCH 2/6] net: ping: remove unneeded initialization Wolfram Sang
2012-04-04 16:04 ` [PATCH 3/6] net: tftp: check for error when retrying Wolfram Sang
2012-04-04 16:04 ` [PATCH 4/6] net: arp_request: do not retry endlessly Wolfram Sang
2012-04-04 16:04 ` Wolfram Sang [this message]
2012-04-04 16:04 ` [PATCH 6/6] net: ping: " Wolfram Sang
2012-04-05 6:56 ` [PATCH 0/6] net: minor cleanups & avoid endless retries Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1333555484-32635-6-git-send-email-w.sang@pengutronix.de \
--to=w.sang@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox