From eb97b502ada1c0b4628de99f2c0c4c9991caaaca Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 3 Oct 2021 15:41:46 -0400 Subject: Track client idle time Bumped on both send and receive. --- bounce.h | 1 + client.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/bounce.h b/bounce.h index af3bcc3..4ee1c7f 100644 --- a/bounce.h +++ b/bounce.h @@ -219,6 +219,7 @@ struct Client { int sock; struct tls *tls; time_t time; + time_t idle; enum Need need; enum Cap caps; size_t consumer; diff --git a/client.c b/client.c index de7b2c9..11962d0 100644 --- a/client.c +++ b/client.c @@ -55,6 +55,7 @@ struct Client *clientAlloc(int sock, struct tls *tls) { client->sock = sock; client->tls = tls; client->time = time(NULL); + client->idle = client->time; client->need = NeedHandshake | NeedNick | NeedUser; if (clientPass) client->need |= NeedPass; return client; @@ -100,6 +101,7 @@ void clientSend(struct Client *client, const char *ptr, size_t len) { len -= ret; } fcntl(client->sock, F_SETFL, O_NONBLOCK); + client->idle = time(NULL); } void clientFormat(struct Client *client, const char *format, ...) { @@ -421,6 +423,7 @@ void clientRecv(struct Client *client) { } client->len -= line - client->buf; memmove(client->buf, line, client->len); + client->idle = time(NULL); } static int wordcmp(const char *line, size_t i, const char *word) { -- cgit 1.4.1