]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Disconnect if socket cannot be put into non-blocking mode
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 12 Mar 2024 08:18:32 +0000 (10:18 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 12 Mar 2024 08:18:51 +0000 (10:18 +0200)
commitbf1f593e899ee9aa1de80164a3005b02474deb50
tree10f4fa2e5d91bc8113588c678ed9f3ab9e300b70
parent5b97461fb068bc348e6b7fc4e5a3b22c86a00b0c
Disconnect if socket cannot be put into non-blocking mode

Commit 387da18874 moved the code to put socket into non-blocking mode
from socket_set_nonblocking() into the one-time initialization
function, pq_init(). In socket_set_nonblocking(), there indeed was a
risk of recursion on failure like the comment said, but in pq_init(),
ERROR or FATAL is fine. There's even another elog(FATAL) just after
this, if setting FD_CLOEXEC fails.

Note that COMMERROR merely logged the error, it did not close the
connection, so if putting the socket to non-blocking mode failed we
would use the connection anyway. You might not immediately notice,
because most socket operations in a regular backend wait for the
socket to become readable/writable anyway. But e.g. replication will
be quite broken.

Backpatch to all supported versions.

Discussion: https://www.postgresql.org/message-id/d40a5cd0-2722-40c5-8755-12e9e811fa3c@iki.fi
src/backend/libpq/pqcomm.c