From 20d41eb261c97654663515683fbdd7446556909c Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Sat, 4 Nov 2017 15:34:34 +0100 Subject: [PATCH] src: improved sessin logging Signed-off-by: Janos SUTO --- src/piler-smtp.c | 4 +++- src/session.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/piler-smtp.c b/src/piler-smtp.c index 6ac8c9ef..7eade8d6 100644 --- a/src/piler-smtp.c +++ b/src/piler-smtp.c @@ -234,7 +234,9 @@ int main(int argc, char **argv){ } if(getnameinfo((struct sockaddr *)&client_address, client_len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0){ - syslog(LOG_PRIORITY, "connected from %s:%s on descriptor %d", hbuf, sbuf, client_sockfd); + // Strictly speaking it's not correct to log num_connections+1 connections + // but it still gives a good clue how many connections we have at the moment + syslog(LOG_PRIORITY, "connected from %s:%s on descriptor %d (active connections: %d)", hbuf, sbuf, client_sockfd, num_connections + 1); } if(make_socket_non_blocking(client_sockfd) == -1){ diff --git a/src/session.c b/src/session.c index fca16326..78148ed3 100644 --- a/src/session.c +++ b/src/session.c @@ -151,7 +151,7 @@ void free_smtp_session(struct smtp_session *session){ void tear_down_session(struct smtp_session **sessions, int slot, int *num_connections){ - syslog(LOG_PRIORITY, "disconnected from %s", sessions[slot]->remote_host); + syslog(LOG_PRIORITY, "disconnected from %s on descriptor %d (%d active connections)", sessions[slot]->remote_host, sessions[slot]->net.socket, (*num_connections)-1); close(sessions[slot]->net.socket);