summaryrefslogtreecommitdiff
path: root/src/backend/libpq/pqcomm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/libpq/pqcomm.c')
-rw-r--r--src/backend/libpq/pqcomm.c51
1 files changed, 22 insertions, 29 deletions
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 49a394be943..e1ecebaf0d1 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -247,28 +247,6 @@ pq_close(int code, Datum arg)
*/
-/* StreamDoUnlink()
- * Shutdown routine for backend connection
- * If any Unix sockets are used for communication, explicitly close them.
- */
-#ifdef HAVE_UNIX_SOCKETS
-static void
-StreamDoUnlink(int code, Datum arg)
-{
- ListCell *l;
-
- /* Loop through all created sockets... */
- foreach(l, sock_paths)
- {
- char *sock_path = (char *) lfirst(l);
-
- unlink(sock_path);
- }
- /* Since we're about to exit, no need to reclaim storage */
- sock_paths = NIL;
-}
-#endif /* HAVE_UNIX_SOCKETS */
-
/*
* StreamServerPort -- open a "listening" port to accept connections.
*
@@ -550,16 +528,11 @@ Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath)
* Once we have the interlock, we can safely delete any pre-existing
* socket file to avoid failure at bind() time.
*/
- unlink(unixSocketPath);
+ (void) unlink(unixSocketPath);
/*
- * Arrange to unlink the socket file(s) at proc_exit. If this is the
- * first one, set up the on_proc_exit function to do it; then add this
- * socket file to the list of files to unlink.
+ * Remember socket file pathnames for later maintenance.
*/
- if (sock_paths == NIL)
- on_proc_exit(StreamDoUnlink, 0);
-
sock_paths = lappend(sock_paths, pstrdup(unixSocketPath));
return STATUS_OK;
@@ -788,6 +761,26 @@ TouchSocketFiles(void)
}
}
+/*
+ * RemoveSocketFiles -- unlink socket files at postmaster shutdown
+ */
+void
+RemoveSocketFiles(void)
+{
+ ListCell *l;
+
+ /* Loop through all created sockets... */
+ foreach(l, sock_paths)
+ {
+ char *sock_path = (char *) lfirst(l);
+
+ /* Ignore any error. */
+ (void) unlink(sock_path);
+ }
+ /* Since we're about to exit, no need to reclaim storage */
+ sock_paths = NIL;
+}
+
/* --------------------------------
* Low-level I/O routines begin here.