diff options
Diffstat (limited to 'src/backend/utils/init/miscinit.c')
-rw-r--r-- | src/backend/utils/init/miscinit.c | 33 |
1 files changed, 32 insertions, 1 deletions
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 *------------------------------------------------------------------------- |