Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Commit bfdf196

Browse files
committed
1 parent 56339ad commit bfdf196

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

swoole_postgresql_coro.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#endif
2828

2929
using namespace swoole;
30+
using swoole::coroutine::System;
3031

3132
PHP_MINIT_FUNCTION(swoole_postgresql);
3233
PHP_MINFO_FUNCTION(swoole_postgresql);
@@ -754,13 +755,16 @@ static PHP_METHOD(swoole_postgresql_coro, query) {
754755
PQclear(pgsql_result);
755756
}
756757

757-
int ret = PQsendQuery(pgsql, Z_STRVAL_P(query));
758-
if (ret == 0) {
758+
if (PQsendQuery(pgsql, Z_STRVAL_P(query)) == 0) {
759759
char *err_msg = PQerrorMessage(pgsql);
760760
zend_update_property_string(swoole_postgresql_coro_ce, SW_Z8_OBJ_P(ZEND_THIS), ZEND_STRL("error"), err_msg);
761761
RETURN_FALSE;
762762
}
763763

764+
while (PQflush(pgsql) == 1) {
765+
System::wait_event(PQsocket(pgsql), SW_EVENT_WRITE, object->timeout);
766+
}
767+
764768
FutureTask *context = php_swoole_postgresql_coro_get_context(ZEND_THIS);
765769
context->coro_params = *ZEND_THIS;
766770

0 commit comments

Comments
 (0)