From 1dc30510884f7f654188b1186988929ab812fd04 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 27 Jan 2001 00:05:31 +0000 Subject: Re-read Unix-socket lock file every so often (every CheckPoint interval, actually) to ensure that its file access time doesn't get old enough to tempt a /tmp directory cleaner to remove it. Still another reason we should never have put the sockets in /tmp in the first place ... --- src/backend/utils/init/miscinit.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/backend/utils/init/miscinit.c') diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index d16dca6ceb9..0ecfa272440 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.60 2001/01/24 19:43:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.61 2001/01/27 00:05:31 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -41,6 +41,9 @@ unsigned char RecodeBackTable[128]; ProcessingMode Mode = InitProcessing; +/* Note: we rely on this to initialize as zeroes */ +static char socketLockFile[MAXPGPATH]; + /* ---------------------------------------------------------------- * ignoring system indexes support stuff @@ -617,9 +620,37 @@ CreateSocketLockFile(const char *socketfile, bool amPostmaster) encoded_pid, socketfile); return false; } + /* Save name of lockfile for TouchSocketLockFile */ + strcpy(socketLockFile, lockfile); return true; } +/* + * Re-read the socket lock file. This should be called every so often + * to ensure that the lock file has a recent access date. That saves it + * from being removed by overenthusiastic /tmp-directory-cleaner daemons. + * (Another reason we should never have put the socket file in /tmp...) + */ +void +TouchSocketLockFile(void) +{ + int fd; + char buffer[1]; + + /* Do nothing if we did not create a socket... */ + if (socketLockFile[0] != '\0') + { + /* XXX any need to complain about errors here? */ + fd = open(socketLockFile, O_RDONLY | PG_BINARY, 0); + if (fd >= 0) + { + read(fd, buffer, sizeof(buffer)); + close(fd); + } + } +} + + /*------------------------------------------------------------------------- * Version checking support *------------------------------------------------------------------------- -- cgit v1.2.3