Use shorter TFTP timeout in blind mode

This commit is contained in:
Joseph C. Lehner 2020-03-02 09:30:27 +01:00
parent 30a2f28f1a
commit da9700c71d
3 changed files with 4 additions and 5 deletions

2
main.c
View file

@ -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,

View file

@ -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];

5
tftp.c
View file

@ -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;