From 38e184dd5ca40fc4ef617a17ca29e7dc0a9745b8 Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Mon, 24 Mar 2025 13:17:21 +0200 Subject: [PATCH] Move WaitEventSetWait after PQgetCopyData --- pgxn/neon/libpagestore.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pgxn/neon/libpagestore.c b/pgxn/neon/libpagestore.c index bec1e1f88e..ff01797189 100644 --- a/pgxn/neon/libpagestore.c +++ b/pgxn/neon/libpagestore.c @@ -1152,16 +1152,16 @@ pageserver_try_receive(shardno_t shard_no) while (true) { - WaitEvent event; - if (WaitEventSetWait(shard->wes_read, 0, &event, 1, - WAIT_EVENT_NEON_PS_READ) != 1 - || (event.events & WL_SOCKET_READABLE) == 0) - { - return NULL; - } rc = PQgetCopyData(shard->conn, &resp_buff.data, 1 /* async */); if (rc == 0) { + WaitEvent event; + if (WaitEventSetWait(shard->wes_read, 0, &event, 1, + WAIT_EVENT_NEON_PS_READ) != 1 + || (event.events & WL_SOCKET_READABLE) == 0) + { + return NULL; + } if (!PQconsumeInput(shard->conn)) { return NULL;