Revised deferring alarm signal

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2019-12-03 21:03:36 +01:00
parent 6b087cf5fd
commit 779175b596
2 changed files with 4 additions and 6 deletions

View File

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <netdb.h> #include <netdb.h>
#include <signal.h>
#include <piler.h> #include <piler.h>
@ -207,7 +208,9 @@ void handle_data(struct smtp_session *session, char *readbuf, int readlen, struc
// pass the puffer to process_data() only if there was an '\n' // pass the puffer to process_data() only if there was an '\n'
// on the line or the puffer does not start with a period // on the line or the puffer does not start with a period
if(session->protocol_state == SMTP_STATE_DATA && (rc == OK || puf[0] != '.')){ if(session->protocol_state == SMTP_STATE_DATA && (rc == OK || puf[0] != '.')){
sig_block(SIGALRM);
process_data(session, puf, puflen); process_data(session, puf, puflen);
sig_unblock(SIGALRM);
} }
else if(session->protocol_state == SMTP_STATE_BDAT){ else if(session->protocol_state == SMTP_STATE_BDAT){
process_bdat(session, puf, puflen, cfg); process_bdat(session, puf, puflen, cfg);

View File

@ -8,7 +8,6 @@
#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>
@ -283,18 +282,14 @@ void process_command_period(struct smtp_session *session){
// TODO: add some error handling // TODO: add some error handling
sig_block(SIGALRM);
gettimeofday(&tv1, &tz); gettimeofday(&tv1, &tz);
fsync(session->fd); fsync(session->fd);
close(session->fd); close(session->fd);
gettimeofday(&tv2, &tz); gettimeofday(&tv2, &tz);
sig_unblock(SIGALRM);
syslog(LOG_PRIORITY, "fsync()+close() took %ld [us]", tvdiff(tv2, tv1));
session->fd = -1; session->fd = -1;
syslog(LOG_PRIORITY, "received: %s, from=%s, size=%d, client=%s, fd=%d", session->ttmpfile, session->mailfrom, session->tot_len, session->remote_host, session->net.socket); syslog(LOG_PRIORITY, "received: %s, from=%s, size=%d, client=%s, fd=%d, fsync=%ld", session->ttmpfile, session->mailfrom, session->tot_len, session->remote_host, session->net.socket, tvdiff(tv2, tv1));
move_email(session); move_email(session);