@@ -277,30 +277,15 @@ socket_close(int code, Datum arg)
277
277
secure_close (MyProcPort );
278
278
279
279
/*
280
- * On most platforms, we leave the socket open until the process dies.
281
- * This allows clients to perform a "synchronous close" if they care
282
- * --- wait till the transport layer reports connection closure, and
283
- * you can be sure the backend has exited. Saves a kernel call, too.
280
+ * Formerly we did an explicit close() here, but it seems better to
281
+ * leave the socket open until the process dies. This allows clients
282
+ * to perform a "synchronous close" if they care --- wait till the
283
+ * transport layer reports connection closure, and you can be sure the
284
+ * backend has exited.
284
285
*
285
- * However, that does not work on Windows: if the kernel closes the
286
- * socket it will invoke an "abortive shutdown" that discards any data
287
- * not yet sent to the client. (This is a flat-out violation of the
288
- * TCP RFCs, but count on Microsoft not to care about that.) To get
289
- * the spec-compliant "graceful shutdown" behavior, we must invoke
290
- * closesocket() explicitly. When using OpenSSL, it seems that clean
291
- * shutdown also requires an explicit shutdown() call.
292
- *
293
- * This code runs late enough during process shutdown that we should
294
- * have finished all externally-visible shutdown activities, so that
295
- * in principle it's good enough to act as a synchronous close on
296
- * Windows too. But it's a lot more fragile than the other way.
286
+ * We do set sock to PGINVALID_SOCKET to prevent any further I/O,
287
+ * though.
297
288
*/
298
- #ifdef WIN32
299
- shutdown (MyProcPort -> sock , SD_SEND );
300
- closesocket (MyProcPort -> sock );
301
- #endif
302
-
303
- /* In any case, set sock to PGINVALID_SOCKET to prevent further I/O */
304
289
MyProcPort -> sock = PGINVALID_SOCKET ;
305
290
}
306
291
}
0 commit comments