1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

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 ...
This commit is contained in:
Tom Lane
2001-01-27 00:05:31 +00:00
parent 1c63587f24
commit 1dc3051088
3 changed files with 43 additions and 3 deletions

View File

@ -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
*-------------------------------------------------------------------------