fixes
[exim.git] / src / src / transport.c
index ed3dcf0af7ccd622332fb1a0454ee5ee62e59e70..cd5e8d3191fc046a06a62ac8f4dbbad52bc2859e 100644 (file)
@@ -265,6 +265,7 @@ for (int i = 0; i < 100; i++)
       }
     else                               /* Timeout wanted. */
       {
+      sigalrm_seen = FALSE;
       ALARM(local_timeout);
        rc = tpt_write(fd, block, len, more, tctx->options);
        save_errno = errno;
@@ -591,14 +592,14 @@ if (include_affixes)
   return addr->address;
   }
 
-if (addr->suffix == NULL)
+if (!addr->suffix)
   {
-  if (addr->prefix == NULL) return addr->address;
+  if (!addr->prefix) return addr->address;
   return addr->address + Ustrlen(addr->prefix);
   }
 
 at = Ustrrchr(addr->address, '@');
-plen = (addr->prefix == NULL)? 0 : Ustrlen(addr->prefix);
+plen = addr->prefix ? Ustrlen(addr->prefix) : 0;
 slen = Ustrlen(addr->suffix);
 
 return string_sprintf("%.*s@%s", (int)(at - addr->address - plen - slen),
@@ -738,10 +739,17 @@ for (header_line * h = header_list; h; h = h->next) if (h->type != htype_old)
            return FALSE;
            }
        len = s ? Ustrlen(s) : 0;
-       if (strncmpic(h->text, s, len) != 0) continue;
-       ss = h->text + len;
-       while (*ss == ' ' || *ss == '\t') ss++;
-       if (*ss == ':') break;
+       if (len && s[len-1] == '*')     /* trailing glob */
+         {
+         if (strncmpic(h->text, s, len-1) == 0) break;
+         }
+       else
+         {
+         if (strncmpic(h->text, s, len) != 0) continue;
+         ss = h->text + len;
+         while (*ss == ' ' || *ss == '\t') ss++;
+         if (*ss == ':') break;
+         }
        }
       if (s) { include_header = FALSE; break; }
       }
@@ -1181,7 +1189,8 @@ transport_write_message(transport_ctx * tctx, int size_limit)
 {
 BOOL last_filter_was_NL = TRUE;
 BOOL save_spool_file_wireformat = f.spool_file_wireformat;
-int rc, len, yield, fd_read, fd_write, save_errno;
+BOOL yield;
+int rc, len, fd_read, fd_write, save_errno;
 int pfd[2] = {-1, -1};
 pid_t filter_pid, write_pid;
 
@@ -1241,7 +1250,7 @@ via a(nother) pipe. While writing to the filter, we do not do the CRLF,
 smtp dots, or check string processing. */
 
 if (pipe(pfd) != 0) goto TIDY_UP;      /* errno set */
-if ((write_pid = fork()) == 0)
+if ((write_pid = exim_fork(US"transport filter writer")) == 0)
   {
   BOOL rc;
   (void)close(fd_read);
@@ -1265,7 +1274,7 @@ if ((write_pid = fork()) == 0)
         != sizeof(struct timeval)
      )
     rc = FALSE;        /* compiler quietening */
-  exim_underbar_exit(0);
+  exim_underbar_exit(0, US"tpt-filter writer");
   }
 save_errno = errno;
 
@@ -1313,6 +1322,7 @@ for (;;)
   ALARM_CLR(0);
   if (sigalrm_seen)
     {
+    DEBUG(D_transport) debug_printf("timed out reading from filter\n");
     errno = ETIMEDOUT;
     f.transport_filter_timed_out = TRUE;
     goto TIDY_UP;
@@ -1431,7 +1441,7 @@ DEBUG(D_transport)
   {
   debug_printf("end of filtering transport writing: yield=%d\n", yield);
   if (!yield)
-    debug_printf("errno=%d more_errno=%d\n", errno, tctx->addr->more_errno);
+    debug_printf(" errno=%d more_errno=%d\n", errno, tctx->addr->more_errno);
   }
 
 return yield;
@@ -1553,12 +1563,17 @@ for (host_item * host = hostlist; host; host = host->next)
 
   /* If this record is full, write it out with a new name constructed
   from the sequence number, increase the sequence number, and empty
-  the record. */
+  the record.  If we're doing a two-phase queue run initial phase, ping the
+  daemon to consider running a delivery on this host. */
 
   if (host_record->count >= WAIT_NAME_MAX)
     {
     sprintf(CS buffer, "%.200s:%d", host->name, host_record->sequence);
     dbfn_write(dbm_file, buffer, host_record, sizeof(dbdata_wait) + host_length);
+#ifdef EXPERIMENTAL_QUEUE_RAMP
+    if (f.queue_2stage && queue_fast_ramp && !queue_run_in_order)
+      queue_notify_daemon(message_id);
+#endif
     host_record->sequence++;
     host_record->count = 0;
     host_length = 0;
@@ -1719,6 +1734,7 @@ while (1)
     }
 
   /* first thing remove current message id if it exists */
+  /*XXX but what if it has un-sent addrs? */
 
   for (i = 0; i < msgq_count; ++i)
     if (Ustrcmp(msgq[i].message_id, message_id) == 0)
@@ -1942,14 +1958,14 @@ int status;
 
 DEBUG(D_transport) debug_printf("transport_pass_socket entered\n");
 
-if ((pid = fork()) == 0)
+if ((pid = exim_fork(US"continued-transport interproc")) == 0)
   {
   /* Disconnect entirely from the parent process. If we are running in the
   test harness, wait for a bit to allow the previous process time to finish,
   write the log, etc., so that the output is always in the same order for
   automatic comparison. */
 
-  if ((pid = fork()) != 0)
+  if ((pid = exim_fork(US"continued-transport")) != 0)
     {
     DEBUG(D_transport) debug_printf("transport_pass_socket succeeded (final-pid %d)\n", pid);
     _exit(EXIT_SUCCESS);