AmendHub

Download:

jcs

/

subtext

/

amendments

/

546

binkp: Remember when we failed connecting and delay next poll

If we had messages in the outbox and triggered a connection which
then failed, the main periodic loop will just pick up those outbox
packets right away and try reconnecting. In that case, don't look
for outbox packets and just use the next poll time.

jcs made amendment 546 5 months ago
--- binkp.c Wed Nov 15 09:23:02 2023 +++ binkp.c Thu Nov 16 13:11:33 2023 @@ -35,6 +35,7 @@ bool binkp_ready = false; time_t binkp_next_poll = 0; +bool binkp_last_poll_error = false; static struct fidopkt_address binkp_our_address = { 0 }; static struct binkp_connection *binkpc = NULL; @@ -129,12 +130,18 @@ binkp_poll(void) char *pkt_buf; unsigned long started = Time, elapsed; + binkp_last_poll_error = false; + binkp_connect(); - if (!binkpc) + if (!binkpc) { + binkp_last_poll_error = true; goto done; + } - if (!binkp_login()) + if (!binkp_login()) { + binkp_last_poll_error = true; goto done; + } while (binkpc != NULL && !binkpc->done_receiving && !binkpc->error) { binkp_read_frame(); @@ -153,6 +160,9 @@ binkp_poll(void) elapsed == 1 ? "" : "s"); done: + if (binkpc->error) + binkp_last_poll_error = true; + if (binkpc != NULL) binkp_free(); --- binkp.h Tue Nov 14 10:55:41 2023 +++ binkp.h Thu Nov 16 13:12:46 2023 @@ -72,6 +72,7 @@ struct binkp_connection { extern bool binkp_ready; extern time_t binkp_next_poll; +extern bool binkp_last_poll_error; void binkp_init(void); bool binkp_reinit(void); --- main.c Thu Nov 9 09:53:43 2023 +++ main.c Thu Nov 16 13:11:58 2023 @@ -473,13 +473,11 @@ periodic_jobs(struct uthread *uthread, void *arg) * Only do polling when no one is on, or we were just woken up * from the sysop menu */ - if (Time > binkp_next_poll) { + if (Time > binkp_next_poll || + (!binkp_last_poll_error && binkp_packets_in_outbox())) { binkp_poll(); uthread_yield(); } - - if (binkp_packets_in_outbox()) - binkp_poll(); } sleep: