From: Joseph C. Lehner Date: Mon, 2 Mar 2020 08:30:27 +0000 (+0100) Subject: Use shorter TFTP timeout in blind mode X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=da9700c71d59d389cb557878656ff4339a017390;p=oweals%2Fnmrpflash.git Use shorter TFTP timeout in blind mode --- diff --git a/main.c b/main.c index 242e7be..58afc56 100644 --- a/main.c +++ b/main.c @@ -133,7 +133,7 @@ int main(int argc, char **argv) int c, val, max; bool list = false, have_dest_mac = false; struct nmrpd_args args = { - .rx_timeout = NMRPFLASH_DEF_RX_TIMEOUT * 1000, + .rx_timeout = 200 * 1000, .ul_timeout = 5 * 60 * 1000, .tftpcmd = NULL, .file_local = NULL, diff --git a/nmrpd.h b/nmrpd.h index c1dc77e..d65c811 100644 --- a/nmrpd.h +++ b/nmrpd.h @@ -72,8 +72,6 @@ #define NMRPFLASH_SET_REGION -#define NMRPFLASH_DEF_RX_TIMEOUT 200 - struct eth_hdr { uint8_t ether_dhost[6]; uint8_t ether_shost[6]; diff --git a/tftp.c b/tftp.c index 5c37693..eb2c314 100644 --- a/tftp.c +++ b/tftp.c @@ -315,7 +315,8 @@ int tftp_put(struct nmrpd_args *args) const char *file_remote = args->file_remote; char *val, *end; bool rollover; - unsigned rx_timeout = MAX(args->rx_timeout / NMRPFLASH_DEF_RX_TIMEOUT, 1000); + const unsigned rx_timeout = MAX(args->rx_timeout / (args->blind ? 50 : 5), 2000); + const unsigned max_timeouts = args->blind ? 3 : 5; sock = -1; ret = -1; @@ -453,7 +454,7 @@ int tftp_put(struct nmrpd_args *args) if (ret < 0) { goto cleanup; } else if (!ret) { - if (++timeouts < 5 || (!block && timeouts < 10)) { + if (++timeouts < max_timeouts || (!block && timeouts < (max_timeouts * 4))) { continue; } else if (args->blind) { timeouts = 0;