Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1dc3051

Browse files
committed
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 ...
1 parent 1c63587 commit 1dc3051

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.203 2001/01/24 19:43:04 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.204 2001/01/27 00:05:31 tgl Exp $
1515
*
1616
* NOTES
1717
*
@@ -788,7 +788,15 @@ ServerLoop(void)
788788
timeout = &timeout_tv;
789789
}
790790
else
791+
{
791792
CheckPointPID = CheckPointDataBase();
793+
/*
794+
* Since this code is executed periodically, it's a fine
795+
* place to do other actions that should happen every now
796+
* and then on no particular schedule. Such as...
797+
*/
798+
TouchSocketLockFile();
799+
}
792800
}
793801

794802
#ifdef USE_SSL

src/backend/utils/init/miscinit.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.60 2001/01/24 19:43:16 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.61 2001/01/27 00:05:31 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -41,6 +41,9 @@ unsigned char RecodeBackTable[128];
4141

4242
ProcessingMode Mode = InitProcessing;
4343

44+
/* Note: we rely on this to initialize as zeroes */
45+
static char socketLockFile[MAXPGPATH];
46+
4447

4548
/* ----------------------------------------------------------------
4649
* ignoring system indexes support stuff
@@ -617,9 +620,37 @@ CreateSocketLockFile(const char *socketfile, bool amPostmaster)
617620
encoded_pid, socketfile);
618621
return false;
619622
}
623+
/* Save name of lockfile for TouchSocketLockFile */
624+
strcpy(socketLockFile, lockfile);
620625
return true;
621626
}
622627

628+
/*
629+
* Re-read the socket lock file. This should be called every so often
630+
* to ensure that the lock file has a recent access date. That saves it
631+
* from being removed by overenthusiastic /tmp-directory-cleaner daemons.
632+
* (Another reason we should never have put the socket file in /tmp...)
633+
*/
634+
void
635+
TouchSocketLockFile(void)
636+
{
637+
int fd;
638+
char buffer[1];
639+
640+
/* Do nothing if we did not create a socket... */
641+
if (socketLockFile[0] != '\0')
642+
{
643+
/* XXX any need to complain about errors here? */
644+
fd = open(socketLockFile, O_RDONLY | PG_BINARY, 0);
645+
if (fd >= 0)
646+
{
647+
read(fd, buffer, sizeof(buffer));
648+
close(fd);
649+
}
650+
}
651+
}
652+
653+
623654
/*-------------------------------------------------------------------------
624655
* Version checking support
625656
*-------------------------------------------------------------------------

src/include/miscadmin.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: miscadmin.h,v 1.79 2001/01/24 19:43:19 momjian Exp $
15+
* $Id: miscadmin.h,v 1.80 2001/01/27 00:05:31 tgl Exp $
1616
*
1717
* NOTES
1818
* some of the information in this file should be moved to
@@ -280,6 +280,7 @@ extern ProcessingMode Mode;
280280

281281
extern bool CreateDataDirLockFile(const char *datadir, bool amPostmaster);
282282
extern bool CreateSocketLockFile(const char *socketfile, bool amPostmaster);
283+
extern void TouchSocketLockFile(void);
283284

284285
extern void ValidatePgVersion(const char *path);
285286

0 commit comments

Comments
 (0)