Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf1f593

Browse files
committed
Disconnect if socket cannot be put into non-blocking mode
Commit387da18 moved the code to put socket into non-blocking modefrom socket_set_nonblocking() into the one-time initializationfunction, pq_init(). In socket_set_nonblocking(), there indeed was arisk of recursion on failure like the comment said, but in pq_init(),ERROR or FATAL is fine. There's even another elog(FATAL) just afterthis, if setting FD_CLOEXEC fails.Note that COMMERROR merely logged the error, it did not close theconnection, so if putting the socket to non-blocking mode failed wewould use the connection anyway. You might not immediately notice,because most socket operations in a regular backend wait for thesocket to become readable/writable anyway. But e.g. replication willbe quite broken.Backpatch to all supported versions.Discussion:https://www.postgresql.org/message-id/d40a5cd0-2722-40c5-8755-12e9e811fa3c@iki.fi
1 parent5b97461 commitbf1f593

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

‎src/backend/libpq/pqcomm.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,10 @@ pq_init(void)
193193
* nonblocking mode and use latches to implement blocking semantics if
194194
* needed. That allows us to provide safely interruptible reads and
195195
* writes.
196-
*
197-
* Use COMMERROR on failure, because ERROR would try to send the error to
198-
* the client, which might require changing the mode again, leading to
199-
* infinite recursion.
200196
*/
201197
#ifndefWIN32
202198
if (!pg_set_noblock(MyProcPort->sock))
203-
ereport(COMMERROR,
199+
ereport(FATAL,
204200
(errmsg("could not set socket to nonblocking mode: %m")));
205201
#endif
206202

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp