From 7ca059d833977d0a89acd9b1e0ae932c9af56a8b Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Tue, 4 Dec 2007 09:22:30 +0000 Subject: [PATCH] log connection age on disconnect --- src/objects.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/objects.c b/src/objects.c index 472797a..de2bb51 100644 --- a/src/objects.c +++ b/src/objects.c @@ -585,9 +585,11 @@ void disconnect_server(PgSocket *server, bool notify, const char *reason) PgSocket *client = server->link; static const uint8_t pkt_term[] = {'X', 0,0,0,4}; int send_term = 1; + usec_t now = get_cached_time(); if (cf_log_disconnections) - slog_info(server, "closing because: %s", reason); + slog_info(server, "closing because: %s (age=%llu)", reason, + (now - server->connect_time) / USEC); switch (server->state) { case SV_ACTIVE: @@ -629,8 +631,11 @@ void disconnect_server(PgSocket *server, bool notify, const char *reason) /* drop client connection */ void disconnect_client(PgSocket *client, bool notify, const char *reason) { + usec_t now = get_cached_time(); + if (cf_log_disconnections) - slog_info(client, "closing because: %s", reason); + slog_info(client, "closing because: %s (age=%llu)", reason, + (now - client->connect_time) / USEC); switch (client->state) { case CL_ACTIVE: -- 2.40.0