diff --git a/VERSIONS b/VERSIONS index 940d754..02173b3 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,5 +1,6 @@ -3.1 -- WORK IN PROGRESS (~April, 2018) +3.1 -- WORK IN PROGRESS (~May, 2018) + * Added: SERVERSILENCETIMEOUT, maximum idle timer for server connection. in case of lost FIN packets * Fixed: Compiles clean with -std=c89 * Added: $guid to esay variables * Added: New bigsay font: spider, use with .bigsay -spider cowabunga! diff --git a/src/core.c b/src/core.c index c2f6236..ae3002a 100644 --- a/src/core.c +++ b/src/core.c @@ -1106,7 +1106,7 @@ void update(SequenceTime *this) /* * Read data from server socket */ -void parse_server_input(void) +void process_server_input(void) { #ifdef WINGATE Server *sp; @@ -1190,7 +1190,8 @@ get_line: } } #endif /* WINGATE */ - parseline(linebuf); + current->conntry = now; + parse_server_input(linebuf); goto get_line; } switch(errno) diff --git a/src/defines.h b/src/defines.h index 682c42a..633f47d 100644 --- a/src/defines.h +++ b/src/defines.h @@ -334,6 +334,8 @@ enum { #define CN_WINGATEWAIT 8 #define CN_SPINNING 9 /* after exhausting serverlist */ +#define SERVERSILENCETIMEOUT 360 /* server connection idle timeout */ + /* DCC Kill flags (BYE command) */ #define DCC_NULL 0 diff --git a/src/h.h b/src/h.h index b185545..bf92ce5 100644 --- a/src/h.h +++ b/src/h.h @@ -196,7 +196,7 @@ void register_with_server(void); int sub_compile_timer(int, uint32_t *, uint32_t *, char *); int compile_timer(HookTimer *, char *); void update(SequenceTime *this); -void parse_server_input(void); +void process_server_input(void); void do_version(COMMAND_ARGS) __page(CMD1_SEG); void do_core(COMMAND_ARGS) __page(CMD1_SEG); void do_die(COMMAND_ARGS) __page(RARE_SEG); @@ -533,7 +533,7 @@ LS void parse_348(char *from, char *rest); LS void parse_368(char *from, char *rest); LS void parse_005(char *from, char *rest); LS uint32_t stringhash(char *s); -LS void parseline(char *rest); +LS void parse_server_input(char *rest); /* partyline.c */ diff --git a/src/main.c b/src/main.c index 5fbc464..f46ed5f 100644 --- a/src/main.c +++ b/src/main.c @@ -780,10 +780,22 @@ restart_dcc: process_dcc(); if (current->sock != -1) - parse_server_input(); + process_server_input(); if (current->connect == CN_ONLINE) { + /* + * Its possible to get stuck waiting forever if a FIN packet is lost + * unless you do this... + */ + if ((current->conntry - now) > SERVERSILENCETIMEOUT) + { + to_server("PING :%lu\n",now); + current->conntry += 10; /* send more unless an answer is received in <10 seconds */ + } + /* + * Keep server idle-timer low to seem like you are chatting + */ if (current->setting[TOG_NOIDLE].int_var) { if ((now - current->lastantiidle) > PINGSENDINTERVAL) diff --git a/src/parse.c b/src/parse.c index 2086567..06fe62e 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1459,7 +1459,7 @@ uint32_t stringhash(char *s) return(hash); } -void parseline(char *rest) +void parse_server_input(char *rest) { #ifdef SCRIPTING Hook *hook; diff --git a/src/structs.h b/src/structs.h index 24a7512..1af6c8c 100644 --- a/src/structs.h +++ b/src/structs.h @@ -578,6 +578,7 @@ typedef struct Mech #endif /* CHANBAN */ time_t conntry; /* when connect try started */ + /* re-used for server activity once connected */ time_t activity; /* Away timer (AAWAY) */ time_t ontime; /* how long the bot has been connected */ diff --git a/src/uptime.c b/src/uptime.c index 9c6c67c..41e332c 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -169,7 +169,7 @@ void send_uptime(int type) if (botlist) { nick = botlist->nick; - upPack.ontime = htonl(botlist->conntry); + upPack.ontime = htonl(botlist->ontime); if ((sp = find_server(botlist->server))) { server = (*sp->realname) ? sp->realname : sp->name;