From fc503a1093f3d971e1bc2082122031a0761bd9ed Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 13 Mar 2026 02:37:33 -0400 Subject: On disconnect or connect fail, sleep between retries, incremental backoff timer. --- src/main.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 59f751e..b62b456 100644 --- a/src/main.c +++ b/src/main.c @@ -23,7 +23,7 @@ void *old_vprced; // old PROCEED vector, restored on exit. unsigned short rxbuflen; // RX buffer length unsigned int txbuflen; // TX buffer length char hz; /* 50 for PAL, 60 for NSTC */ -char reconnect_timeout; +char reconnect_timeout = 1; /* TODO: user modes (default +iw), fg/bg color... */ @@ -92,11 +92,10 @@ int fn_connect(void) { err = nopen(conf->url, FNET_TRANSLATION); if(err != SUCCESS) { - bell(); scr_print_current("Connection failed: "); print_errnum(); scr_eol_current(); - cgetc(); + bell(); return 0; } @@ -131,6 +130,27 @@ void init_channels(void) { } void reconnect_wait(void) { + scr_display(SCR_SERVER); + scr_print_current("Press a key"); + + /* IMO, 0xff is easier to understand than KEY_NONE, here */ + OS.cdtmf3 = OS.ch = 0xff; + + if(reconnect_timeout) { + OS.cdtmv3 = reconnect_timeout * hz; + scr_print_current(" or wait "); + itoa(reconnect_timeout, numbuf, 10); + scr_print_current(numbuf); + scr_print_current(" sec"); + if(reconnect_timeout < 64) + reconnect_timeout <<= 1; + } + scr_print_current(" to reconnect.\n"); + + while(OS.cdtmf3 == 0xff && OS.ch == 0xff) + /* NOP */; + + OS.ch = 0xff; } void main(void) { @@ -152,9 +172,8 @@ void main(void) { if(fn_connect()) { irc_register(); irc_loop(); - fn_disconnect(); - } else { - reconnect_wait(); } + fn_disconnect(); + reconnect_wait(); } } -- cgit v1.2.3