hirc

IRC client
Log | Files | Refs

commit b10e4b7b02f55f9478a18f96805eb22afe2d48bc
parent bbb22f6ec23b81208c381317fa336bc7aca9db48
Author: hhvn <dev@hhvn.uk>
Date:   Sun, 14 Nov 2021 14:42:21 +0000

main.c serv.c: don't send QUIT when server is likely dead already

Diffstat:
Mmain.c | 4++--
Mserv.c | 5+++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c @@ -140,7 +140,7 @@ ircprintf(struct Server *server, char *format, ...) { ret = write(server->wfd, msg, strlen(msg)); if (ret == -1 && server->status == ConnStatus_connected) { - serv_disconnect(server, 1, "Eead Rrror"); + serv_disconnect(server, 1, NULL); hist_format(server->history, Activity_error, HIST_SHOW, "SELF_CONNECTLOST %s %s %s :%s", server->name, server->host, server->port, strerror(errno)); @@ -252,7 +252,7 @@ main(int argc, char *argv[]) { } else if (sp->pingsent && (time(NULL) - sp->pingsent) >= pinginact) { /* haven't gotten a response in pinginact seconds since * sending ping, this connexion is probably dead now */ - serv_disconnect(sp, 1, "Eead Rror"); + serv_disconnect(sp, 1, NULL); hist_format(sp->history, Activity_error, HIST_SHOW, "SELF_CONNECTLOST %s %s %s :No ping reply in %d seconds", sp->name, sp->host, sp->port, pinginact); diff --git a/serv.c b/serv.c @@ -233,7 +233,7 @@ serv_connect(struct Server *server) { return; fail: - serv_disconnect(server, 1, "Eead Rrror"); + serv_disconnect(server, 1, NULL); if (server->connectfail * config_getl("reconnect.interval") < config_getl("reconnect.maxinterval")) server->connectfail += 1; freeaddrinfo(ai); @@ -275,7 +275,8 @@ serv_poll(struct Server **head, int timeout) { void serv_disconnect(struct Server *server, int reconnect, char *msg) { - ircprintf(server, "QUIT %s\r\n", msg); + if (msg) + ircprintf(server, "QUIT %s\r\n", msg); shutdown(server->rfd, SHUT_RDWR); shutdown(server->wfd, SHUT_RDWR); close(server->rfd);