use php_pq_callback_recurse
authorMichael Wallner <mike@php.net>
Mon, 14 Jul 2014 11:28:47 +0000 (13:28 +0200)
committerMichael Wallner <mike@php.net>
Mon, 14 Jul 2014 11:28:47 +0000 (13:28 +0200)
src/php_pqconn.c
src/php_pqstm.c

index a1492f0b8af5a9adb64ad5e37d56f6f93ad02cb9..66b5d9f63e106eda534ed1cd41acf39c33c4c2c0 100644 (file)
@@ -906,12 +906,8 @@ static PHP_METHOD(pqconn, execAsync) {
                } else if (obj->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn)) {
                        throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn));
                } else {
+                       php_pq_callback_recurse(&obj->intern->onevent, &resolver TSRMLS_CC);
                        obj->intern->poller = PQconsumeInput;
-                       php_pq_callback_dtor(&obj->intern->onevent);
-                       if (resolver.fci.size > 0) {
-                               obj->intern->onevent = resolver;
-                               php_pq_callback_addref(&obj->intern->onevent);
-                       }
                        php_pqconn_notify_listeners(obj TSRMLS_CC);
                }
        }
@@ -999,12 +995,8 @@ static PHP_METHOD(pqconn, execParamsAsync) {
                        } else if (obj->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn)) {
                                throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn));
                        } else {
+                               php_pq_callback_recurse(&obj->intern->onevent, &resolver TSRMLS_CC);
                                obj->intern->poller = PQconsumeInput;
-                               php_pq_callback_dtor(&obj->intern->onevent);
-                               if (resolver.fci.size > 0) {
-                                       obj->intern->onevent = resolver;
-                                       php_pq_callback_addref(&obj->intern->onevent);
-                               }
                                php_pqconn_notify_listeners(obj TSRMLS_CC);
                        }
                }
index 6be580cf0607a24a35c94440250a523e6bfa5265..d9ec1eab1c689663079aff228b614a9dad56e5c5 100644 (file)
@@ -244,11 +244,7 @@ static PHP_METHOD(pqstm, execAsync) {
                        } else if (obj->intern->conn->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn->intern->conn)) {
                                throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
                        } else {
-                               php_pq_callback_dtor(&obj->intern->conn->intern->onevent);
-                               if (resolver.fci.size > 0) {
-                                       obj->intern->conn->intern->onevent = resolver;
-                                       php_pq_callback_addref(&obj->intern->conn->intern->onevent);
-                               }
+                               php_pq_callback_recurse(&obj->intern->conn->intern->onevent, &resolver TSRMLS_CC);
                                obj->intern->conn->intern->poller = PQconsumeInput;
                        }
 
@@ -313,11 +309,7 @@ static PHP_METHOD(pqstm, descAsync) {
                } else if (!PQsendDescribePrepared(obj->intern->conn->intern->conn, obj->intern->name)) {
                        throw_exce(EX_IO TSRMLS_CC, "Failed to describe statement: %s", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
                } else {
-                       php_pq_callback_dtor(&obj->intern->conn->intern->onevent);
-                       if (resolver.fci.size > 0) {
-                               obj->intern->conn->intern->onevent = resolver;
-                               php_pq_callback_addref(&obj->intern->conn->intern->onevent);
-                       }
+                       php_pq_callback_recurse(&obj->intern->conn->intern->onevent, &resolver TSRMLS_CC);
                        obj->intern->conn->intern->poller = PQconsumeInput;
                        php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC);
                }