print connection age in disconnect message
authorMarko Kreen <markokr@gmail.com>
Mon, 3 Dec 2007 13:11:33 +0000 (13:11 +0000)
committerMarko Kreen <markokr@gmail.com>
Mon, 3 Dec 2007 13:11:33 +0000 (13:11 +0000)
src/objects.c

index 0316376e210316498d9dfd4bb32753f2a428a7e8..4876602adbab437804df851af41288b224a04b55 100644 (file)
@@ -653,9 +653,11 @@ void disconnect_server(PgSocket *server, bool notify, const char *reason)
        PgSocket *client = server->link;
        static const uint8 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:
@@ -697,8 +699,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: