simplify the PLPROXY_IDLE_CONN_CHECK related code
authorMarko Kreen <markokr@gmail.com>
Thu, 6 Dec 2007 15:04:59 +0000 (15:04 +0000)
committerMarko Kreen <markokr@gmail.com>
Thu, 6 Dec 2007 15:04:59 +0000 (15:04 +0000)
src/execute.c
src/plproxy.h

index 338b6e3660e5ee3d2024b8b058f23021487a435c..592f07f0e21504eecae3bfdb723e75fde36d7644 100644 (file)
  * - Tag particural databases, where query must be sent.
  * - Send the query.
  * - Fetch the results.
- *
- * Fixme:
- * - should also loop over untagged connections, waiting for READ events?
- *      that would allow to track conn status better.
  */
 
 #include "plproxy.h"
@@ -220,19 +216,12 @@ check_old_conn(ProxyFunction *func, ProxyConnection *conn, struct timeval * now)
 
        /* how long ts been idle */
        t = now->tv_sec - conn->query_time;
-#ifdef PLPROXY_IDLE_CONN_CHECK
        if (t < PLPROXY_IDLE_CONN_CHECK)
-#else
-       if (1)
-#endif
                return true;
 
        /*
-        * There was a idea to call PQconsumeInput couple of times on a long-idle
-        * connections, to see if they are still alive.
-        *
-        * As this is complicated, then ATM just do a select(,,,0) on fd.
-        * Stable conn should have no events pending.
+        * Simple way to check if old connection is stable - look if there
+        * are events pending.  If there are drop the connection.
         */
 intr_loop:
        fd = PQsocket(conn->db);
index 96b734a9fa9e42990466abc07c1369dceefd2598..21fc140a0ddafe70378a5c2b70d0cf5a9ce2718c 100644 (file)
@@ -70,9 +70,9 @@
 
 /*
  * Check connections that are idle more than this many seconds.
- * Undefine to disable.
+ * Set 0 to always check.
  */
-#define PLPROXY_IDLE_CONN_CHECK                10
+#define PLPROXY_IDLE_CONN_CHECK                2
 
 /* Flag indicating where function should be executed */
 typedef enum RunOnType