#include <hesiod.h>
#endif
+#include "getopt.h"
#include "fetchmail.h"
#include "tunable.h"
#include "smtp.h"
netrc_entry *netrc_list;
char *netrc_file, *tmpbuf;
pid_t pid;
+ int lastsig = 0;
#ifdef __FreeBSD__
dropprivs();
/* logging should be set up early in case we were restarted from exec */
if (run.use_syslog)
{
+#if defined(LOG_MAIL)
openlog(program_name, LOG_PID, LOG_MAIL);
+#else
+ /* Assume BSD4.2 openlog with two arguments */
+ openlog(program_name, LOG_PID);
+#endif
report_init(-1);
}
else
}
#if (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__)
- /* interface_approve() does its own error logging */
- if (!interface_approve(&ctl->server))
+ /*
+ * Don't do monitoring if we were woken by a signal.
+ * Note that interface_approve() does its own error logging.
+ */
+ if (!interface_approve(&ctl->server, !lastsig))
continue;
#endif /* (defined(linux) && !INET6_ENABLE) || defined(__FreeBSD__) */
*/
if (run.poll_interval)
{
- int lastsig;
-
/*
* Because passwords can expire, it may happen that *all*
* hosts are now out of the loop due to authfail
/*
* OK, now pause util it's time for the next poll cycle.
- * A TRUE return indicates we received a wakeup signal;
+ * A nonzero return indicates we received a wakeup signal;
* unwedge all servers in case the problem has been
* manually repaired.
*/
- if ((lastsig = idle(run.poll_interval)))
+ if ((lastsig = interruptible_idle(run.poll_interval)))
{
#ifdef SYS_SIGLIST_DECLARED
report(stdout,
exit(successes ? PS_SUCCESS : querystatus);
}
-static void optmerge(struct query *h2, struct query *h1, int force)
-/* merge two options records */
+static void list_merge(struct idlist **dstl, struct idlist **srcl, int force)
{
/*
- * If force is off, modify h2 fields only when they're empty (treat h1
- * as defaults). If force is on, modify each h2 field whenever h1
- * is nonempty (treat h1 as an override).
+ * If force is off, modify dstl fields only when they're empty (treat srcl
+ * as defaults). If force is on, modify each dstl field whenever scrcl
+ * is nonempty (treat srcl as an override).
*/
-#define LIST_MERGE(dstl, srcl) if (force ? !!srcl : !dstl) \
- free_str_list(&dstl), \
- append_str_list(&dstl, &srcl)
- LIST_MERGE(h2->server.localdomains, h1->server.localdomains);
- LIST_MERGE(h2->localnames, h1->localnames);
- LIST_MERGE(h2->mailboxes, h1->mailboxes);
- LIST_MERGE(h2->smtphunt, h1->smtphunt);
- LIST_MERGE(h2->antispam, h1->antispam);
-#undef LIST_MERGE
+ if (force ? !!*srcl : !*dstl)
+ {
+ struct idlist *cpl = copy_str_list(*srcl);
+
+ append_str_list(dstl, &cpl);
+ }
+}
+
+static void optmerge(struct query *h2, struct query *h1, int force)
+/* merge two options records */
+{
+ list_merge(&h2->server.localdomains, &h1->server.localdomains, force);
+ list_merge(&h2->localnames, &h1->localnames, force);
+ list_merge(&h2->mailboxes, &h1->mailboxes, force);
+ list_merge(&h2->smtphunt, &h1->smtphunt, force);
+ list_merge(&h2->antispam, &h1->antispam, force);
#define FLAG_MERGE(fld) if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld
FLAG_MERGE(server.via);