diff --git a/src/piler-smtp.c b/src/piler-smtp.c index df8ada84..91481069 100644 --- a/src/piler-smtp.c +++ b/src/piler-smtp.c @@ -40,6 +40,7 @@ struct passwd *pwd; struct smtp_session *session, **sessions=NULL; struct smtp_acl *smtp_acl[MAXHASH]; +time_t prev_timeout_check = 0; void usage(){ printf("\nusage: piler\n\n"); @@ -90,6 +91,8 @@ void check_for_client_timeout(){ if(cfg.verbosity >= LOG_DEBUG) syslog(LOG_PRIORITY, "%s @%ld", __func__, now); + if(now - prev_timeout_check < cfg.smtp_timeout) return; + if(num_connections > 0){ for(int i=0; ilasttime >= cfg.smtp_timeout){ @@ -98,6 +101,8 @@ void check_for_client_timeout(){ } } } + + time(&prev_timeout_check); } @@ -194,6 +199,7 @@ int main(int argc, char **argv){ set_signal_handler(SIGSEGV, p_clean_exit); set_signal_handler(SIGPIPE, SIG_IGN); + set_signal_handler(SIGALRM, SIG_IGN); set_signal_handler(SIGHUP, initialise_configuration); @@ -216,7 +222,7 @@ int main(int argc, char **argv){ #endif for(;;){ - int n = epoll_wait(efd, events, cfg.max_connections, 10000); + int n = epoll_wait(efd, events, cfg.max_connections, 1000); for(i=0; ilasttime)); while(1){ - memset(readbuf, 0, sizeof(readbuf)); - if(session->net.use_ssl == 1) readlen = SSL_read(session->net.ssl, (char*)&readbuf[0], sizeof(readbuf)-1); else diff --git a/src/session.c b/src/session.c index 80fa0a4e..777679a9 100644 --- a/src/session.c +++ b/src/session.c @@ -119,23 +119,17 @@ void init_smtp_session(struct smtp_session *session, int slot, int sd, char *cli void free_smtp_session(struct smtp_session *session){ if(session){ - syslog(LOG_PRIORITY, "free_smtp_session()"); if(session->net.use_ssl == 1){ - syslog(LOG_PRIORITY, "SSL_shutdown()"); SSL_shutdown(session->net.ssl); SSL_free(session->net.ssl); - syslog(LOG_PRIORITY, "SSL_free()"); } if(session->net.ctx){ - syslog(LOG_PRIORITY, "SSL_CTX_free"); SSL_CTX_free(session->net.ctx); } - syslog(LOG_PRIORITY, "freeing session"); free(session); - syslog(LOG_PRIORITY, "free(session) done"); } } @@ -183,6 +177,7 @@ void handle_data(struct smtp_session *session, char *readbuf, int readlen, struc p = ©buf[0]; } else { + readbuf[readlen] = 0; p = readbuf; }