summaryrefslogtreecommitdiffstats
path: root/fs/tftp.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-10-23 10:11:13 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-24 09:57:44 +0200
commitd2606de353cc60b0c7a9db054bca991670ebc9b0 (patch)
treecb3d213bde537f970403afb993ad8cefa98988e8 /fs/tftp.c
parent5e463658080a20fe71d7979e83ce6a74dcf6382f (diff)
downloadbarebox-d2606de353cc60b0c7a9db054bca991670ebc9b0.tar.gz
barebox-d2606de353cc60b0c7a9db054bca991670ebc9b0.tar.xz
fs tftp: Only request a block once
tftp_send is called often. Each time, when in STATE_RDATA, a packet is requested from the tftp server, even if we requested the same packet already. Stop this by tracking which packet we requested. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs/tftp.c')
-rw-r--r--fs/tftp.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/tftp.c b/fs/tftp.c
index ae57f95300..d89272e5ec 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -80,6 +80,7 @@ struct file_priv {
struct kfifo *fifo;
void *buf;
int blocksize;
+ int block_requested;
};
struct tftp_priv {
@@ -152,11 +153,14 @@ static int tftp_send(struct file_priv *priv)
break;
case STATE_RDATA:
+ if (priv->block == priv->block_requested)
+ return 0;
case STATE_OACK:
xp = pkt;
s = (uint16_t *)pkt;
*s++ = htons(TFTP_ACK);
*s++ = htons(priv->block);
+ priv->block_requested = priv->block;
pkt = (unsigned char *)s;
len = pkt - xp;
break;
@@ -199,6 +203,7 @@ static int tftp_poll(struct file_priv *priv)
if (is_timeout(priv->resend_timeout, TFTP_RESEND_TIMEOUT)) {
printf("T ");
priv->resend_timeout = get_time_ns();
+ priv->block_requested = -1;
return TFTP_ERR_RESEND;
}
@@ -392,6 +397,7 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
priv->err = -EINVAL;
priv->filename = filename;
priv->blocksize = TFTP_BLOCK_SIZE;
+ priv->block_requested = -1;
priv->fifo = kfifo_alloc(4096);
if (!priv->fifo) {