piler-smtp wont scare users with epoll error if the remote end just disconnected

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2017-11-01 07:54:16 +01:00
parent 677abfe295
commit c96693f98f
2 changed files with 7 additions and 3 deletions

View File

@ -11,7 +11,7 @@
#define VERSION "1.3.2" #define VERSION "1.3.2"
#define BUILD 981 #define BUILD 982
#define HOSTID "mailarchiver" #define HOSTID "mailarchiver"
@ -62,6 +62,7 @@
#define _LOG_INFO 3 #define _LOG_INFO 3
#define _LOG_DEBUG 5 #define _LOG_DEBUG 5
#define _LOG_EXTREME 100
#define MAX_RCPT_TO 128 #define MAX_RCPT_TO 128

View File

@ -206,8 +206,11 @@ 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
// We log the event only in case of a very high verbosity level
// so it won't scare users
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))){
syslog(LOG_PRIORITY, "ERROR: epoll error"); if(cfg.verbosity >= _LOG_EXTREME) syslog(LOG_PRIORITY, "ERROR: the remote end hung up without sending QUIT");
close(events[i].data.fd); close(events[i].data.fd);
continue; continue;
} }
@ -275,7 +278,7 @@ int main(int argc, char **argv){
else else
readlen = read(events[i].data.fd, (char*)&readbuf[0], sizeof(readbuf)-1); readlen = read(events[i].data.fd, (char*)&readbuf[0], sizeof(readbuf)-1);
if(cfg.verbosity >= _LOG_DEBUG && readlen > 0) syslog(LOG_PRIORITY, "got %ld bytes to read", readlen); if(cfg.verbosity >= _LOG_EXTREME && readlen > 0) syslog(LOG_PRIORITY, "got %ld bytes to read", readlen);
if(readlen == -1){ if(readlen == -1){
/* If errno == EAGAIN, that means we have read all data. So go back to the main loop. */ /* If errno == EAGAIN, that means we have read all data. So go back to the main loop. */