diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/postmaster/postmaster.c | 10 | ||||
-rw-r--r-- | src/backend/utils/init/miscinit.c | 33 | ||||
-rw-r--r-- | src/include/miscadmin.h | 3 |
3 files changed, 43 insertions, 3 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 3d7c1cb9f57..98fff8b6af0 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.203 2001/01/24 19:43:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.204 2001/01/27 00:05:31 tgl Exp $ * * NOTES * @@ -788,7 +788,15 @@ ServerLoop(void) timeout = &timeout_tv; } else + { CheckPointPID = CheckPointDataBase(); + /* + * Since this code is executed periodically, it's a fine + * place to do other actions that should happen every now + * and then on no particular schedule. Such as... + */ + TouchSocketLockFile(); + } } #ifdef USE_SSL 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 *------------------------------------------------------------------------- diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 93b153c4a16..fa73145787b 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -12,7 +12,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: miscadmin.h,v 1.79 2001/01/24 19:43:19 momjian Exp $ + * $Id: miscadmin.h,v 1.80 2001/01/27 00:05:31 tgl Exp $ * * NOTES * some of the information in this file should be moved to @@ -280,6 +280,7 @@ extern ProcessingMode Mode; extern bool CreateDataDirLockFile(const char *datadir, bool amPostmaster); extern bool CreateSocketLockFile(const char *socketfile, bool amPostmaster); +extern void TouchSocketLockFile(void); extern void ValidatePgVersion(const char *path); |