Skip to content

Commit

Permalink
Fix for replying to keepalive-acks more correctly. (Should decrease t…
Browse files Browse the repository at this point in the history
…he amount of unexpected timeouts)
  • Loading branch information
haakonnessjoen committed Jul 1, 2014
1 parent 0cc4cfe commit 698650a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mactelnetd.c
Expand Up @@ -123,6 +123,7 @@ struct mt_connection {
unsigned short seskey;
unsigned int incounter;
unsigned int outcounter;
unsigned int lastack;
time_t lastdata;

int terminal_mode;
Expand Down Expand Up @@ -746,9 +747,10 @@ static void handle_packet(unsigned char *data, int data_len, const struct sockad

if (pkthdr.counter <= curconn->outcounter) {
curconn->wait_for_ack = 0;
curconn->lastack = pkthdr.counter;
}

if (time(0) - curconn->lastdata > 9) {
if (time(0) - curconn->lastdata > 9 || pkthdr.counter == curconn->lastack) {
// Answer to anti-timeout packet
init_packet(&pdata, MT_PTYPE_ACK, pkthdr.dstaddr, pkthdr.srcaddr, pkthdr.seskey, pkthdr.counter);
send_udp(curconn, &pdata);
Expand Down

0 comments on commit 698650a

Please sign in to comment.