mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:51:59 +01:00
Further improved the session timeout handling
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
50a2328f64
commit
1283e33e50
@ -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; i<cfg.max_connections; i++){
|
||||
if(sessions[i] && now - sessions[i]->lasttime >= 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; i<n; i++){
|
||||
|
||||
// Office365 sometimes behaves oddly: when it receives the 250 OK
|
||||
@ -295,8 +301,6 @@ int main(int argc, char **argv){
|
||||
time(&(session->lasttime));
|
||||
|
||||
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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user