summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/src/exim.c16
-rw-r--r--src/src/functions.h1
-rw-r--r--src/src/log.c16
3 files changed, 25 insertions, 8 deletions
diff --git a/src/src/exim.c b/src/src/exim.c
index acc2af715..f05ba78a8 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -5531,7 +5531,7 @@ while (more)
ignored; rejecting here would just add complication, and it can just as
well be done later. Allow $recipients to be visible in the ACL. */
- if (acl_not_smtp_start != NULL)
+ if (acl_not_smtp_start)
{
uschar *user_msg, *log_msg;
enable_dollar_recipients = TRUE;
@@ -5540,6 +5540,20 @@ while (more)
enable_dollar_recipients = FALSE;
}
+ /* 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. */
+
+ if (!receive_timeout)
+ {
+ struct timeval t = { 30*60, 0 }; /* 30 minutess */
+ fd_set r;
+
+ FD_ZERO(&r); FD_SET(0, &r);
+ if (select(1, &r, NULL, NULL, &t) == 0) mainlog_close();
+ }
+
/* Read the data for the message. If filter_test is not FTEST_NONE, this
will just read the headers for the message, and not write anything onto the
spool. */
diff --git a/src/src/functions.h b/src/src/functions.h
index b31a89fbc..fd1e11d1b 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -246,6 +246,7 @@ extern int log_create_as_exim(uschar *);
extern void log_close_all(void);
extern macro_item * macro_create(const uschar *, const uschar *, BOOL);
+extern void mainlog_close(void);
#ifdef WITH_CONTENT_SCAN
extern int malware(const uschar *, int);
extern int malware_in_file(uschar *);
diff --git a/src/src/log.c b/src/src/log.c
index fbf1042e7..6eb57ca75 100644
--- a/src/src/log.c
+++ b/src/src/log.c
@@ -663,6 +663,14 @@ while ((t = string_nextinlist(&tt, &sep, log_buffer, LOG_BUFFER_SIZE)))
}
+void
+mainlog_close(void)
+{
+if (mainlogfd < 0) return;
+(void)close(mainlogfd);
+mainlogfd = -1;
+mainlog_inode = 0;
+}
/*************************************************
* Write message to log file *
@@ -1004,14 +1012,8 @@ if ( flags & LOG_MAIN
happening. */
if (mainlogfd >= 0)
- {
if (Ustat(mainlog_name, &statbuf) < 0 || statbuf.st_ino != mainlog_inode)
- {
- (void)close(mainlogfd);
- mainlogfd = -1;
- mainlog_inode = 0;
- }
- }
+ mainlog_close();
/* If the log is closed, open it. Then write the line. */