chiark / gitweb /
info in lockfile
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Tue, 27 Apr 2010 20:29:42 +0000 (21:29 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Tue, 27 Apr 2010 20:29:42 +0000 (21:29 +0100)
backends/innduct.c
doc/man/innduct.8

index 620354f01c2d45b36889ee1be37b471b5ef23537..1fd382835ec9c1355bcd70827585a2bba703e7d1 100644 (file)
@@ -1903,8 +1903,10 @@ static void statemc_init(void) {
   path_defer=       xasprintf("%s_defer",     feedfile);
   globpat_backlog=  xasprintf("%s_backlog*",  feedfile);
 
+  int lockfd;
+  
   for (;;) {
-    int lockfd= open(path_lock, O_CREAT|O_RDWR, 0600);
+    lockfd= open(path_lock, O_CREAT|O_RDWR, 0600);
     if (lockfd<0) sysfatal("open lockfile %s", path_lock);
 
     struct flock fl;
@@ -1929,6 +1931,20 @@ static void statemc_init(void) {
 
     xclose(lockfd, "stale lockfile ", path_lock);
   }
+  pid_t self= getpid();
+  if (self==-1) sysdie("getpid");
+
+  FILE *lockfile= fdopen(lockfd, "w");
+  if (!lockfile) sysdie("fdopen lockfile");
+
+  int r= ftruncate(lockfd, 0);
+  if (r) sysdie("truncate lockfile to write new info");
+
+  if (fprintf(lockfile, "pid %ld\nsite %s\nfeedfile %s\nfqdn %s\n",
+             (unsigned long)self, sitename, feedfile, remote_host) == EOF ||
+      fflush(lockfile))
+    sysfatal("write info to lockfile %s", path_lock);
+
   debug("startup: locked");
 
   search_backlog_file();
index d5f6be024d33ba2f17efe30925c61adc7a63b0bc..72ee35ff2c37cc7fbb746d9a3005e98de68bd3d8 100644 (file)
@@ -344,6 +344,16 @@ feed.  A process holds this lock after it has opened the lockfile,
 made an fcntl F_SETLK call, and then checked with stat and fstat that
 the file it now has open and has locked still has the name
 \fIfeedfile\fR_lock.  (Only) the lockholder may delete the lockfile.
+For your convenience, after the lockfile is locked,
+.IR innfeed 's
+pid, the
+.IR site ,
+.IR feedfile
+and
+.IR fqdn
+are all written to the lockfile.  NB that stale lockfiles may contain
+stale data so this information should not be relied on other than for
+troubleshooting.
 .IP \fIfeedfile\fR_flushing
 .IX Item "flushing file"
 Batch file: the main feedfile is renamed to this filename by innduct