]> granicus.if.org Git - pgbouncer/commitdiff
log connection age on disconnect
authorMarko Kreen <markokr@gmail.com>
Tue, 4 Dec 2007 09:22:30 +0000 (09:22 +0000)
committerMarko Kreen <markokr@gmail.com>
Tue, 4 Dec 2007 09:22:30 +0000 (09:22 +0000)
src/objects.c

index 472797ac08bd2273ad330590a8106ab0a5162ac0..de2bb517b11d5c2be5c63996b729c468bc08121c 100644 (file)
@@ -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: