mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 08:00:12 +01:00
Protect fsync() and close() from SIGALRM
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
34e25f6c74
commit
52e7e6293c
@ -66,8 +66,8 @@ listen_port=25
|
|||||||
|
|
||||||
clamd_socket=/tmp/clamd
|
clamd_socket=/tmp/clamd
|
||||||
|
|
||||||
; check for client timeout interval. Default: 30 sec
|
; check for client timeout interval. Default: 20 sec
|
||||||
check_for_client_timeout_interval=30
|
check_for_client_timeout_interval=20
|
||||||
|
|
||||||
; smtp timeout. Default: 60 sec
|
; smtp timeout. Default: 60 sec
|
||||||
smtp_timeout=60
|
smtp_timeout=60
|
||||||
|
@ -62,7 +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_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)},
|
{ "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)},
|
{ "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)},
|
{ "check_for_client_timeout_interval", "integer", (void*) int_parser, offsetof(struct config, check_for_client_timeout_interval), "20", 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},
|
{ "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_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)},
|
{ "clamd_port", "integer", (void*) int_parser, offsetof(struct config, clamd_port), "0", sizeof(int)},
|
||||||
|
@ -77,7 +77,7 @@ void __fatal(char *s){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calculate the difference betwwen two timevals in [usec]
|
* calculate the difference between two timevals in [usec]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
long tvdiff(struct timeval a, struct timeval b){
|
long tvdiff(struct timeval a, struct timeval b){
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
@ -266,13 +267,21 @@ void process_command_data(struct smtp_session *session, struct config *cfg){
|
|||||||
|
|
||||||
void process_command_period(struct smtp_session *session){
|
void process_command_period(struct smtp_session *session){
|
||||||
char buf[SMALLBUFSIZE];
|
char buf[SMALLBUFSIZE];
|
||||||
|
struct timezone tz;
|
||||||
|
struct timeval tv1, tv2;
|
||||||
|
|
||||||
session->protocol_state = SMTP_STATE_PERIOD;
|
session->protocol_state = SMTP_STATE_PERIOD;
|
||||||
|
|
||||||
// TODO: add some error handling
|
// TODO: add some error handling
|
||||||
|
|
||||||
|
sig_block(SIGALRM);
|
||||||
|
gettimeofday(&tv1, &tz);
|
||||||
fsync(session->fd);
|
fsync(session->fd);
|
||||||
close(session->fd);
|
close(session->fd);
|
||||||
|
gettimeofday(&tv2, &tz);
|
||||||
|
sig_unblock(SIGALRM);
|
||||||
|
|
||||||
|
syslog(LOG_PRIORITY, "fsync()+close() took %ld [us]", tvdiff(tv2, tv1));
|
||||||
|
|
||||||
session->fd = -1;
|
session->fd = -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user