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;
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();
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