Skip to content

Commit

Permalink
Fix pgsql non blocking (#5485)
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFreeman authored Sep 20, 2024
1 parent 7d2de71 commit c9b8b5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions ext-src/swoole_oracle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#ifdef SW_USE_ORACLE

using swoole::Coroutine;

static bool swoole_oracle_blocking = true;
void swoole_oracle_set_blocking(bool blocking) {
swoole_oracle_blocking = blocking;
Expand Down
7 changes: 6 additions & 1 deletion ext-src/swoole_pgsql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#ifdef SW_USE_PGSQL

using swoole::Reactor;
using swoole::Coroutine;
using swoole::coroutine::Socket;
using swoole::coroutine::translate_events_to_poll;

Expand Down Expand Up @@ -92,7 +93,11 @@ PGconn *swoole_pgsql_connectdb(const char *conninfo) {
return conn;
}

PQsetnonblocking(conn, 1);
if (!swoole_pgsql_blocking && Coroutine::get_current()) {
PQsetnonblocking(conn, 1);
} else {
PQsetnonblocking(conn, 0);
}

SW_LOOP {
int r = PQconnectPoll(conn);
Expand Down

0 comments on commit c9b8b5a

Please sign in to comment.