src: fixing aborted connection handling, mostly from o365

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2017-11-05 08:35:01 +01:00
parent 20d41eb261
commit 9646225ae9

View File

@ -206,12 +206,17 @@ int main(int argc, char **argv){
n = epoll_wait(efd, events, cfg.max_connections, -1); n = epoll_wait(efd, events, cfg.max_connections, -1);
for(i=0; i<n; i++){ for(i=0; i<n; i++){
// The remote side has disconnected without sending QUIT // Office365 sometimes behaves oddly: when it receives the 250 OK
// We log the event only in case of a very high verbosity level // message after sending the email, it doesn't send the QUIT command
// so it won't scare users // rather it aborts the connection
if((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))){ if((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))){
if(cfg.verbosity >= _LOG_EXTREME) syslog(LOG_PRIORITY, "ERROR: the remote end hung up without sending QUIT"); if(cfg.verbosity >= _LOG_EXTREME) syslog(LOG_PRIORITY, "ERROR: the remote end hung up without sending QUIT");
close(events[i].data.fd); session = get_session_by_socket(sessions, cfg.max_connections, events[i].data.fd);
if(session)
tear_down_session(sessions, session->slot, &num_connections);
else
close(events[i].data.fd);
continue; continue;
} }