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

Commit268313a

Browse files
committed
Don't explicitly close() the session socket during backend exit; instead
leave it for the kernel to do after the process dies. This allows clientsto wait for the backend to exit if they wish (after sending X message,wait till EOF is detected on the socket).
1 parent9f47c4c commit268313a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

‎src/backend/libpq/pqcomm.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
3131
* Portions Copyright (c) 1994, Regents of the University of California
3232
*
33-
*$Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.153 2003/05/15 16:35:28 momjian Exp $
33+
*$Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.154 2003/05/29 19:15:34 tgl Exp $
3434
*
3535
*-------------------------------------------------------------------------
3636
*/
@@ -149,9 +149,17 @@ pq_close(void)
149149
{
150150
if (MyProcPort!=NULL)
151151
{
152+
/* Cleanly shut down SSL layer */
152153
secure_close(MyProcPort);
153-
closesocket(MyProcPort->sock);
154-
/* make sure any subsequent attempts to do I/O fail cleanly */
154+
/*
155+
* Formerly we did an explicit close() here, but it seems better
156+
* to leave the socket open until the process dies. This allows
157+
* clients to perform a "synchronous close" if they care --- wait
158+
* till the transport layer reports connection closure, and you
159+
* can be sure the backend has exited.
160+
*
161+
* We do set sock to -1 to prevent any further I/O, though.
162+
*/
155163
MyProcPort->sock=-1;
156164
}
157165
}
@@ -470,6 +478,13 @@ StreamConnection(int server_fd, Port *port)
470478

471479
/*
472480
* StreamClose -- close a client/backend connection
481+
*
482+
* NOTE: this is NOT used to terminate a session; it is just used to release
483+
* the file descriptor in a process that should no longer have the socket
484+
* open. (For example, the postmaster calls this after passing ownership
485+
* of the connection to a child process.) It is expected that someone else
486+
* still has the socket open. So, we only want to close the descriptor,
487+
* we do NOT want to send anything to the far end.
473488
*/
474489
void
475490
StreamClose(intsock)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp