mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-05 23:59:20 +02:00
Revert "graceful shutdown" changes for Windows, in back branches only.
This reverts commits6051857fc
anded52c3707
, but only in the back branches. Further testing has shown that while those changes do fix some things, they also break others; in particular, it looks like walreceivers fail to detect walsender-initiated connection close reliably if the walsender shuts down this way. We'll keep trying to improve matters in HEAD, but it now seems unwise to push these changes into stable releases. Discussion: https://postgr.es/m/CA+hUKG+OeoETZQ=Qw5Ub5h3tmwQhBmDA=nuNO3KG=zWfUypFAw@mail.gmail.com
This commit is contained in:
parent
2ccd8fb29d
commit
64b2c6507e
@ -286,30 +286,15 @@ socket_close(int code, Datum arg)
|
|||||||
secure_close(MyProcPort);
|
secure_close(MyProcPort);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* On most platforms, we leave the socket open until the process dies.
|
* Formerly we did an explicit close() here, but it seems better to
|
||||||
* This allows clients to perform a "synchronous close" if they care
|
* leave the socket open until the process dies. This allows clients
|
||||||
* --- wait till the transport layer reports connection closure, and
|
* to perform a "synchronous close" if they care --- wait till the
|
||||||
* you can be sure the backend has exited. Saves a kernel call, too.
|
* transport layer reports connection closure, and you can be sure the
|
||||||
|
* backend has exited.
|
||||||
*
|
*
|
||||||
* However, that does not work on Windows: if the kernel closes the
|
* We do set sock to PGINVALID_SOCKET to prevent any further I/O,
|
||||||
* socket it will invoke an "abortive shutdown" that discards any data
|
* though.
|
||||||
* not yet sent to the client. (This is a flat-out violation of the
|
|
||||||
* TCP RFCs, but count on Microsoft not to care about that.) To get
|
|
||||||
* the spec-compliant "graceful shutdown" behavior, we must invoke
|
|
||||||
* closesocket() explicitly. When using OpenSSL, it seems that clean
|
|
||||||
* shutdown also requires an explicit shutdown() call.
|
|
||||||
*
|
|
||||||
* This code runs late enough during process shutdown that we should
|
|
||||||
* have finished all externally-visible shutdown activities, so that
|
|
||||||
* in principle it's good enough to act as a synchronous close on
|
|
||||||
* Windows too. But it's a lot more fragile than the other way.
|
|
||||||
*/
|
*/
|
||||||
#ifdef WIN32
|
|
||||||
shutdown(MyProcPort->sock, SD_SEND);
|
|
||||||
closesocket(MyProcPort->sock);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* In any case, set sock to PGINVALID_SOCKET to prevent further I/O */
|
|
||||||
MyProcPort->sock = PGINVALID_SOCKET;
|
MyProcPort->sock = PGINVALID_SOCKET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user