From 34e25f6c74bd7fdbdaa4db3d47159fd414b853c2 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Wed, 27 Nov 2019 20:47:04 +0100 Subject: [PATCH] Introduced check_for_client_timeout_interval config parameter Signed-off-by: Janos SUTO --- etc/example.conf | 3 +++ src/cfg.c | 1 + src/cfg.h | 1 + src/piler-smtp.c | 5 ++--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/etc/example.conf b/etc/example.conf index dc7a4d12..739a236c 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -66,6 +66,9 @@ listen_port=25 clamd_socket=/tmp/clamd +; check for client timeout interval. Default: 30 sec +check_for_client_timeout_interval=30 + ; smtp timeout. Default: 60 sec smtp_timeout=60 diff --git a/src/cfg.c b/src/cfg.c index 490011b6..a49cf16a 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -62,6 +62,7 @@ struct _parse_rule config_parse_rules[] = { "archive_emails_not_having_message_id", "integer", (void*) int_parser, offsetof(struct config, archive_emails_not_having_message_id), "0", sizeof(int)}, { "archive_only_mydomains", "integer", (void*) int_parser, offsetof(struct config, archive_only_mydomains), "0", sizeof(int)}, { "backlog", "integer", (void*) int_parser, offsetof(struct config, backlog), "20", sizeof(int)}, + { "check_for_client_timeout_interval", "integer", (void*) int_parser, offsetof(struct config, check_for_client_timeout_interval), "30", sizeof(int)}, { "cipher_list", "string", (void*) string_parser, offsetof(struct config, cipher_list), "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS", MAXVAL-1}, { "clamd_addr", "string", (void*) string_parser, offsetof(struct config, clamd_addr), "", MAXVAL-1}, { "clamd_port", "integer", (void*) int_parser, offsetof(struct config, clamd_port), "0", sizeof(int)}, diff --git a/src/cfg.h b/src/cfg.h index 9bf7df84..03ea7d12 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -49,6 +49,7 @@ struct config { int verbosity; char locale[MAXVAL]; + int check_for_client_timeout_interval; int smtp_timeout; int helper_timeout; int extract_attachments; diff --git a/src/piler-smtp.c b/src/piler-smtp.c index f87ecaf2..9ecff3bf 100644 --- a/src/piler-smtp.c +++ b/src/piler-smtp.c @@ -31,7 +31,6 @@ extern char *optarg; extern int optind; struct epoll_event event, *events=NULL; -int timeout = 20; // checking for timeout this often [sec] int num_connections = 0; int listenerfd = -1; @@ -98,7 +97,7 @@ void check_for_client_timeout(){ } } - alarm(timeout); + alarm(cfg.check_for_client_timeout_interval); } @@ -216,7 +215,7 @@ int main(int argc, char **argv){ if(daemonise == 1 && daemon(1, 0) == -1) fatal(ERR_DAEMON); #endif - alarm(timeout); + alarm(cfg.check_for_client_timeout_interval); for(;;){ n = epoll_wait(efd, events, cfg.max_connections, -1);