+/* Pause for a while waiting for input. If none received in that time,
+close the logfile, if we had one open; then if we wait for a long-running
+datasource (months, in one use-case) log rotation will not leave us holding
+the file copy. */
+
+static void
+log_close_chk(void)
+{
+if (!receive_timeout)
+ {
+ struct timeval t;
+ timesince(&t, &received_time);
+ if (t.tv_sec > 30*60)
+ mainlog_close();
+ else
+ {
+ fd_set r;
+ FD_ZERO(&r); FD_SET(0, &r);
+ t.tv_sec = 30*60 - t.tv_sec; t.tv_usec = 0;
+ if (select(1, &r, NULL, NULL, &t) == 0) mainlog_close();
+ }
+ }
+}
+