From 6dc0521ba88d2dbf4ac0ca773b0726ebc2b998a7 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sat, 13 Sep 2014 08:56:29 +0200 Subject: [PATCH] ping server and eventually reset conn on wakeup --- src/php_pqconn.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/php_pqconn.c b/src/php_pqconn.c index 2588d42..dedd1f4 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -541,7 +541,12 @@ php_resource_factory_ops_t *php_pqconn_get_resource_factory_ops(void) static void php_pqconn_wakeup(php_persistent_handle_factory_t *f, void **handle TSRMLS_DC) { - // FIXME: ping server + PGresult *res = PQexec(*handle, ""); + PHP_PQclear(res); + + if (CONNECTION_OK != PQstatus(*handle)) { + PQreset(*handle); + } } static inline PGresult *unlisten(PGconn *conn, const char *channel_str, size_t channel_len TSRMLS_DC) -- 2.30.2