]> granicus.if.org Git - pgbouncer/commitdiff
Apply client_login_timeout to clients waiting for welcome pkt
authorMarko Kreen <markokr@gmail.com>
Fri, 4 Dec 2009 10:28:46 +0000 (10:28 +0000)
committerMarko Kreen <markokr@gmail.com>
Fri, 4 Dec 2009 10:28:46 +0000 (10:28 +0000)
Otherwise the clients stay waiting infinitely, unless there is query_timeout set.

This only applies for servers that have never been up.  If server has
been connected once, the query_timeout is only thing that kills clients,
as clients are let freely log in after first connect to server.

src/janitor.c

index 0de654e8f1e40aaf86981e2b8711270842013bfd..5da7e6834297c3b8c292f5a2079bc0fa3741dda1 100644 (file)
@@ -338,6 +338,16 @@ static void pool_client_maint(PgPool *pool)
                                disconnect_client(client, true, "query_timeout");
                }
        }
+
+       /* apply client_login_timeout to clients waiting for welcome pkt */
+       if (cf_client_login_timeout > 0 && !pool->welcome_msg_ready) {
+               statlist_for_each_safe(item, &pool->waiting_client_list, tmp) {
+                       client = container_of(item, PgSocket, head);
+                       age = now - client->connect_time;
+                       if (age > cf_client_login_timeout)
+                               disconnect_client(client, true, "client_login_timeout (server down)");
+               }
+       }
 }
 
 static void check_unused_servers(PgPool *pool, StatList *slist, bool idle_test)