circo

claudio's IRC oasis
git clone git://git.bitsmanent.org/circo
Log | Files | Refs | README | LICENSE

commit e0f843a33203d449fe27784837ef3e5d3dc9c02c
parent aeb6d46cd9baf1720e20144fcb04ad75ebbe5ca6
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sat, 21 Apr 2018 13:16:08 +0200

New function hangsup(): disconnect.

Diffstat:
Mcirco.c | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/circo.c b/circo.c @@ -125,6 +125,7 @@ void focusnext(const Arg *arg); void focusprev(const Arg *arg); void freebuf(Buffer *b); int getkey(void); +void hangsup(void); void history(const Arg *arg); void histpush(char *buf, int len); void logw(char *txt); @@ -322,6 +323,7 @@ cmd_server(char *cmd, char *s) { char *h, *p; int fd; + hangsup(); p = skip(s, ' '); h = s; if(!*h) @@ -673,6 +675,14 @@ getkey(void) { } void +hangsup(void) { + if(!srv) + return; + fclose(srv); + srv = NULL; +} + +void history(const Arg *arg) { int nl, n, i; @@ -968,8 +978,7 @@ run(void) { if(n == 0) { if(srv) { if(time(NULL) - trespond >= 300) { - fclose(srv); - srv = NULL; + hangsup(); for(b = buffers; b; b = b->next) bprintf(b, "Connection timeout.\n"); } @@ -980,8 +989,7 @@ run(void) { else { if(srv && FD_ISSET(fileno(srv), &rd)) { if(fgets(bufin, sizeof bufin, srv) == NULL) { - fclose(srv); - srv = NULL; + hangsup(); for(b = buffers; b; b = b->next) bprintf(b, "Remote host closed connection.\n"); }