From: Marko Kreen Date: Tue, 4 Dec 2007 09:22:30 +0000 (+0000) Subject: log connection age on disconnect X-Git-Tag: pgbouncer_1_2_rc2~119 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ca059d833977d0a89acd9b1e0ae932c9af56a8b;p=pgbouncer log connection age on disconnect --- 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: