+ connection_id = getpid();
+
+ /* Log the connection if requested.
+ In order to minimize the cost (because this is going to happen for every
+ connection), do a preliminary selector test here. This saves ploughing through
+ the generalized logging code each time when the selector is false. If the
+ selector is set, check whether the host is on the list for logging. If not,
+ arrange to unset the selector in the subprocess.
+
+ jgh 2023/08/08 :- moved this logging in from the parent process, just
+ pre-fork. There was a claim back from 2004 that smtp_accept_count could have
+ become out-of-date by the time the child could log it, and I can't see how
+ that could happen. */
+
+ if (LOGGING(smtp_connection))
+ {
+ uschar * list = hosts_connection_nolog;
+ memset(sender_host_cache, 0, sizeof(sender_host_cache));
+ if (list && verify_check_host(&list) == OK)
+ save_log_selector &= ~L_smtp_connection;
+ else if (LOGGING(connection_id))
+ log_write(L_smtp_connection, LOG_MAIN, "SMTP connection from %Y "
+ "Ci=%lu (TCP/IP connection count = %d)", whofrom, connection_id, smtp_accept_count);
+ else
+ log_write(L_smtp_connection, LOG_MAIN, "SMTP connection from %Y "
+ "(TCP/IP connection count = %d)", whofrom, smtp_accept_count);
+ }