diff options
author | erdgeist <> | 2013-07-15 19:06:35 +0000 |
---|---|---|
committer | erdgeist <> | 2013-07-15 19:06:35 +0000 |
commit | f409a5e841d91237fe4034818955dd88167a679b (patch) | |
tree | bebaf6f812c1278357294f80b46bba8ff0883134 | |
parent | 959d7d76aec53f03463223ee64afb805e1865464 (diff) |
add a global tcp-keepalive-option. thanks to Fefe
-rwxr-xr-x | vchat-client.c | 2 | ||||
-rwxr-xr-x | vchat-config.h | 1 | ||||
-rwxr-xr-x | vchat-protocol.c | 7 | ||||
-rwxr-xr-x | vchat.h | 3 |
4 files changed, 11 insertions, 2 deletions
diff --git a/vchat-client.c b/vchat-client.c index 71a596c..f5cd516 100755 --- a/vchat-client.c +++ b/vchat-client.c | |||
@@ -43,6 +43,8 @@ int status = 1; | |||
43 | int ownquit = 0; | 43 | int ownquit = 0; |
44 | /* we set this, we DONT want to quit */ | 44 | /* we set this, we DONT want to quit */ |
45 | int wantreconnect = 0; | 45 | int wantreconnect = 0; |
46 | unsigned int want_tcp_keepalive = 0; | ||
47 | |||
46 | static int reconnect_delay = 6; | 48 | static int reconnect_delay = 6; |
47 | static time_t reconnect_time = 0; | 49 | static time_t reconnect_time = 0; |
48 | 50 | ||
diff --git a/vchat-config.h b/vchat-config.h index 96fed27..8392d18 100755 --- a/vchat-config.h +++ b/vchat-config.h | |||
@@ -55,6 +55,7 @@ static volatile configoption configoptions[] = { | |||
55 | {CF_BELLPRIV, CO_INT, "bellonpm", (char *) 0, (char *)-1, { NULL } }, | 55 | {CF_BELLPRIV, CO_INT, "bellonpm", (char *) 0, (char *)-1, { NULL } }, |
56 | {CF_CASEFIRST, CO_INT, "casefirst", (char *) 0, (char *)-1, { .pint = &ul_case_first } }, | 56 | {CF_CASEFIRST, CO_INT, "casefirst", (char *) 0, (char *)-1, { .pint = &ul_case_first } }, |
57 | {CF_AUTORECONN, CO_INT, "autoreconn", (char *) 0, (char *)-1, { NULL } }, | 57 | {CF_AUTORECONN, CO_INT, "autoreconn", (char *) 0, (char *)-1, { NULL } }, |
58 | {CF_KEEPALIVE, CO_INT, "keepalive", (char *) 0, (char *)-1, { .pint = &want_tcp_keepalive } }, | ||
58 | {CF_NIL, CO_NIL, NULL, NULL, NULL, { NULL } }, | 59 | {CF_NIL, CO_NIL, NULL, NULL, NULL, { NULL } }, |
59 | }; | 60 | }; |
60 | 61 | ||
diff --git a/vchat-protocol.c b/vchat-protocol.c index b9a5e15..b50f511 100755 --- a/vchat-protocol.c +++ b/vchat-protocol.c | |||
@@ -92,6 +92,11 @@ static int connect_socket( char *server, char *port ) { | |||
92 | break; /* okay we got one */ | 92 | break; /* okay we got one */ |
93 | } | 93 | } |
94 | freeaddrinfo(res0); | 94 | freeaddrinfo(res0); |
95 | |||
96 | if (want_tcp_keepalive) { /* global from vchat-client.c */ | ||
97 | int one=1; | ||
98 | setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,&one,sizeof(one)); | ||
99 | } | ||
95 | return s; | 100 | return s; |
96 | } | 101 | } |
97 | 102 | ||
@@ -373,7 +378,7 @@ justloggedin (char *message) | |||
373 | /* we're not logged in, change status and request nicks */ | 378 | /* we're not logged in, change status and request nicks */ |
374 | if (!loggedin) | 379 | if (!loggedin) |
375 | { | 380 | { |
376 | loadcfg(getstroption(CF_LOGINSCRIPT),handleline); | 381 | loadcfg(getstroption(CF_LOGINSCRIPT),0,handleline); |
377 | handleline(".S"); | 382 | handleline(".S"); |
378 | loggedin = 1; | 383 | loggedin = 1; |
379 | } | 384 | } |
@@ -33,7 +33,7 @@ typedef enum { CF_NIL, CF_NICK, CF_FROM, CF_SERVERHOST, CF_SERVERPORT, | |||
33 | CF_CIPHERSUITE, CF_CONFIGFILE, CF_CERTFILE, CF_KEYFILE, CF_FORMFILE, CF_LOGINSCRIPT, | 33 | CF_CIPHERSUITE, CF_CONFIGFILE, CF_CERTFILE, CF_KEYFILE, CF_FORMFILE, CF_LOGINSCRIPT, |
34 | CF_USESSL, CF_IGNSSL, CF_USECERT, CF_PRIVHEIGHT, CF_PRIVCOLLAPS, CF_HSCROLL, CF_CHANNEL, CF_USETIME, | 34 | CF_USESSL, CF_IGNSSL, CF_USECERT, CF_PRIVHEIGHT, CF_PRIVCOLLAPS, CF_HSCROLL, CF_CHANNEL, CF_USETIME, |
35 | CF_USETOPIC, CF_SCROLLBPRIV, CF_SCROLLBACK, CF_SCROLLBPRIVT, CF_SCROLLBACKT, | 35 | CF_USETOPIC, CF_SCROLLBPRIV, CF_SCROLLBACK, CF_SCROLLBPRIVT, CF_SCROLLBACKT, |
36 | CF_ENCODING, CF_BELLPRIV, CF_CASEFIRST, CF_AUTORECONN } confopt; | 36 | CF_ENCODING, CF_BELLPRIV, CF_CASEFIRST, CF_AUTORECONN, CF_KEEPALIVE } confopt; |
37 | 37 | ||
38 | /* format strings */ | 38 | /* format strings */ |
39 | typedef enum { FS_PLAIN, FS_CHAN, FS_PRIV, FS_SERV, FS_GLOB, FS_DBG, FS_ERR, | 39 | typedef enum { FS_PLAIN, FS_CHAN, FS_PRIV, FS_SERV, FS_GLOB, FS_DBG, FS_ERR, |
@@ -75,6 +75,7 @@ typedef struct formatstring formatstring; | |||
75 | static char tmpstr[TMPSTRSIZE]; | 75 | static char tmpstr[TMPSTRSIZE]; |
76 | 76 | ||
77 | extern unsigned int loggedin; | 77 | extern unsigned int loggedin; |
78 | extern unsigned int want_tcp_keepalive; | ||
78 | 79 | ||
79 | /* vchat-client.c */ | 80 | /* vchat-client.c */ |
80 | #define ERRSTRSIZE 1024 | 81 | #define ERRSTRSIZE 1024 |