From b01dd148c3a5f3a70817b08e41ad21aeee1d8f28 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Tue, 23 Jan 2007 14:34:02 +0000 Subject: [PATCH] Add $smtp_count_at_connection_start. --- doc/doc-txt/ChangeLog | 4 +++- doc/doc-txt/NewStuff | 13 ++++++++++++- src/src/daemon.c | 6 ++++-- src/src/expand.c | 3 ++- src/src/smtp_in.c | 10 +++++----- test/confs/0022 | 3 ++- test/log/0022 | 2 ++ test/stderr/0022 | 2 ++ 8 files changed, 32 insertions(+), 11 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index cbda709f7..b8795a62f 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.460 2007/01/23 12:33:08 magnus Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.461 2007/01/23 14:34:02 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -50,6 +50,8 @@ PH/07 There was a bug in the dovecot authenticator such that the value of successful authentication. This usually meant that the value preserved by the server_setid option was incorrect. +PH/08 Added $smtp_count_at_connection_start, deliberately with a long name. + Exim version 4.66 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index ac707ae40..3fe06394f 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/NewStuff,v 1.129 2007/01/22 16:29:54 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/NewStuff,v 1.130 2007/01/23 14:34:02 ph10 Exp $ New Features in Exim -------------------- @@ -186,6 +186,17 @@ Version 4.67 When ENABLE_DISABLE_FSYNC is not set, a reference to disable_fsync in a runtime configuration generates an "unknown option" error. + 5. There is a new variable called $smtp_count_at_connection_start. The name + is deliberately long, in order to emphasize what the contents are. This + variable is set greater than zero only in processes spawned by the Exim + daemon for handling incoming SMTP connections. When the daemon accepts a + new connection, it increments this variable. A copy of the variable is + passed to the child process that handles the connection, but its value is + fixed, and never changes. It is only an approximation of how many incoming + connections there actually are, because many other connections may come and + go while a single connection is being processed. When a child process + terminates, the daemon decrements the variable. + Version 4.66 ------------ diff --git a/src/src/daemon.c b/src/src/daemon.c index 1e639453c..4c6c90878 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/daemon.c,v 1.21 2007/01/17 11:29:39 ph10 Exp $ */ +/* $Cambridge: exim/src/src/daemon.c,v 1.22 2007/01/23 14:34:02 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -369,6 +369,8 @@ if (pid == 0) struct sigaction act; #endif + smtp_accept_count++; /* So that it includes this process */ + /* May have been modified for the subprocess */ log_write_selector = use_log_write_selector; @@ -459,7 +461,7 @@ if (pid == 0) configured value and may therefore already be TRUE. Leave logging till later so it will have a message id attached. */ - if (smtp_accept_queue > 0 && smtp_accept_count >= smtp_accept_queue) + if (smtp_accept_queue > 0 && smtp_accept_count > smtp_accept_queue) { local_queue_only = TRUE; queue_only_reason = 1; diff --git a/src/src/expand.c b/src/src/expand.c index c7a4749d9..03cc85a80 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.76 2007/01/08 11:56:41 ph10 Exp $ */ +/* $Cambridge: exim/src/src/expand.c,v 1.77 2007/01/23 14:34:02 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -528,6 +528,7 @@ static var_entry var_table[] = { { "smtp_active_hostname", vtype_stringptr, &smtp_active_hostname }, { "smtp_command", vtype_stringptr, &smtp_cmd_buffer }, { "smtp_command_argument", vtype_stringptr, &smtp_cmd_argument }, + { "smtp_count_at_connection_start", vtype_int, &smtp_accept_count }, { "sn0", vtype_filter_int, &filter_sn[0] }, { "sn1", vtype_filter_int, &filter_sn[1] }, { "sn2", vtype_filter_int, &filter_sn[2] }, diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index ea7039935..b6a6669e9 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/smtp_in.c,v 1.51 2007/01/18 15:35:42 ph10 Exp $ */ +/* $Cambridge: exim/src/src/smtp_in.c,v 1.52 2007/01/23 14:34:02 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1594,18 +1594,18 @@ if (!sender_host_unknown) } #endif - /* Check for reserved slots. Note that the count value doesn't include - this process, as it gets upped in the parent process. */ + /* Check for reserved slots. The value of smtp_accept_count has already been + incremented to include this process. */ if (smtp_accept_max > 0 && - smtp_accept_count + 1 > smtp_accept_max - smtp_accept_reserve) + smtp_accept_count > smtp_accept_max - smtp_accept_reserve) { if ((rc = verify_check_host(&smtp_reserve_hosts)) != OK) { log_write(L_connection_reject, LOG_MAIN, "temporarily refused connection from %s: not in " "reserve list: connected=%d max=%d reserve=%d%s", - host_and_ident(FALSE), smtp_accept_count, smtp_accept_max, + host_and_ident(FALSE), smtp_accept_count - 1, smtp_accept_max, smtp_accept_reserve, (rc == DEFER)? " (lookup deferred)" : ""); smtp_printf("421 %s: Too many concurrent SMTP connections; " "please try again later\r\n", smtp_active_hostname); diff --git a/test/confs/0022 b/test/confs/0022 index 2ec64d848..5fa25b0aa 100644 --- a/test/confs/0022 +++ b/test/confs/0022 @@ -66,7 +66,8 @@ delay_warn: accept freeze: - accept control = freeze + accept logwrite = Connections=$smtp_count_at_connection_start + control = freeze queue_only: accept control = queue_only diff --git a/test/log/0022 b/test/log/0022 index ad8e75454..5db88e150 100644 --- a/test/log/0022 +++ b/test/log/0022 @@ -1,3 +1,4 @@ +1999-03-02 09:44:33 Connections=0 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex U=CALLER P=local-smtp S=sss 1999-03-02 09:44:33 10HmaX-0005vi-00 frozen by ACL 1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@test.ex U=CALLER P=local-smtp S=sss @@ -11,6 +12,7 @@ ******** SERVER ******** 1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225 +1999-03-02 09:44:33 Connections=1 1999-03-02 09:44:33 10HmbB-0005vi-00 <= x@y H=[127.0.0.1] P=smtp S=sss 1999-03-02 09:44:33 10HmbB-0005vi-00 frozen by ACL 1999-03-02 09:44:33 10HmbC-0005vi-00 <= x@y H=[127.0.0.1] P=smtp S=sss diff --git a/test/stderr/0022 b/test/stderr/0022 index 4835ebd39..08de42bea 100644 --- a/test/stderr/0022 +++ b/test/stderr/0022 @@ -290,6 +290,8 @@ LOG: H=[V4NET.9.8.7] F= rejected RCPT : host data >A host-sp LOG: SMTP connection from [V4NET.9.8.7] closed by QUIT LOG: smtp_connection MAIN SMTP connection from CALLER +LOG: MAIN + Connections=0 LOG: MAIN <= CALLER@test.ex U=CALLER P=local-smtp S=sss LOG: MAIN -- 2.25.1