]> git.pld-linux.org Git - packages/exim.git/blob - exim-bug-1891.patch
- rel 5; update from git
[packages/exim.git] / exim-bug-1891.patch
1 commit 3c55eef24050cec9e50e98e2f5fc12cd45f1ef8a
2 Author: Jeremy Harris <jgh146exb@wizmail.org>
3 Date:   Fri Apr 5 15:22:20 2019 +0100
4
5     Logging: close logfile when non-smtp input is taking a long time.  Bug 1891
6
7 diff --git a/src/src/receive.c b/src/src/receive.c
8 index 0cb38626..64f62757 100644
9 --- a/src/src/receive.c
10 +++ b/src/src/receive.c
11 @@ -571,6 +571,30 @@ return FALSE;
12  
13  
14  
15 +/* Pause for a while waiting for input.  If none received in that time,
16 +close the logfile, if we had one open; then if we wait for a long-running
17 +datasource (months, in one use-case) log rotation will not leave us holding
18 +the file copy. */
19 +
20 +static void
21 +log_close_chk(void)
22 +{
23 +if (!receive_timeout)
24 +  {
25 +  struct timeval t;
26 +  timesince(&t, &received_time);
27 +  if (t.tv_sec > 30*60)
28 +    mainlog_close();
29 +  else
30 +    {
31 +    fd_set r;
32 +    FD_ZERO(&r); FD_SET(0, &r);
33 +    t.tv_sec = 30*60 - t.tv_sec; t.tv_usec = 0;
34 +    if (select(1, &r, NULL, NULL, &t) == 0) mainlog_close();
35 +    }
36 +  }
37 +}
38 +
39  /*************************************************
40  *     Read data portion of a non-SMTP message    *
41  *************************************************/
42 @@ -619,9 +643,11 @@ register int linelength = 0;
43  
44  if (!f.dot_ends)
45    {
46 -  register int last_ch = '\n';
47 +  int last_ch = '\n';
48  
49 -  for (; (ch = (receive_getc)(GETC_BUFFER_UNLIMITED)) != EOF; last_ch = ch)
50 +  for ( ;
51 +       log_close_chk(), (ch = (receive_getc)(GETC_BUFFER_UNLIMITED)) != EOF;
52 +       last_ch = ch)
53      {
54      if (ch == 0) body_zerocount++;
55      if (last_ch == '\r' && ch != '\n')
56 @@ -663,7 +689,7 @@ if (!f.dot_ends)
57  
58  ch_state = 1;
59  
60 -while ((ch = (receive_getc)(GETC_BUFFER_UNLIMITED)) != EOF)
61 +while (log_close_chk(), (ch = (receive_getc)(GETC_BUFFER_UNLIMITED)) != EOF)
62    {
63    if (ch == 0) body_zerocount++;
64    switch (ch_state)
This page took 0.026867 seconds and 3 git commands to generate.