about summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-10-03 15:41:46 -0400
committerJune McEnroe <june@causal.agency>2021-10-03 15:41:46 -0400
commiteb97b502ada1c0b4628de99f2c0c4c9991caaaca (patch)
tree63145ec1c341a19587ae26d9abefdc8ca9970cb3 /client.c
parentLog IRC to standard output with -v (diff)
downloadpounce-eb97b502ada1c0b4628de99f2c0c4c9991caaaca.tar.gz
pounce-eb97b502ada1c0b4628de99f2c0c4c9991caaaca.zip
Track client idle time
Bumped on both send and receive.
Diffstat (limited to 'client.c')
-rw-r--r--client.c3
1 files changed, 3 insertions, 0 deletions
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) {