Commit 1dc30510 authored by Tom Lane's avatar Tom Lane

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 ...
parent 1c63587f
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* *
...@@ -788,7 +788,15 @@ ServerLoop(void) ...@@ -788,7 +788,15 @@ ServerLoop(void)
timeout = &timeout_tv; timeout = &timeout_tv;
} }
else else
{
CheckPointPID = CheckPointDataBase(); 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 #ifdef USE_SSL
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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]; ...@@ -41,6 +41,9 @@ unsigned char RecodeBackTable[128];
ProcessingMode Mode = InitProcessing; ProcessingMode Mode = InitProcessing;
/* Note: we rely on this to initialize as zeroes */
static char socketLockFile[MAXPGPATH];
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* ignoring system indexes support stuff * ignoring system indexes support stuff
...@@ -617,9 +620,37 @@ CreateSocketLockFile(const char *socketfile, bool amPostmaster) ...@@ -617,9 +620,37 @@ CreateSocketLockFile(const char *socketfile, bool amPostmaster)
encoded_pid, socketfile); encoded_pid, socketfile);
return false; return false;
} }
/* Save name of lockfile for TouchSocketLockFile */
strcpy(socketLockFile, lockfile);
return true; 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 * Version checking support
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * 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 * NOTES
* some of the information in this file should be moved to * some of the information in this file should be moved to
...@@ -280,6 +280,7 @@ extern ProcessingMode Mode; ...@@ -280,6 +280,7 @@ extern ProcessingMode Mode;
extern bool CreateDataDirLockFile(const char *datadir, bool amPostmaster); extern bool CreateDataDirLockFile(const char *datadir, bool amPostmaster);
extern bool CreateSocketLockFile(const char *socketfile, bool amPostmaster); extern bool CreateSocketLockFile(const char *socketfile, bool amPostmaster);
extern void TouchSocketLockFile(void);
extern void ValidatePgVersion(const char *path); extern void ValidatePgVersion(const char *path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment