Fixed using the lasttime smtp session variable

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2019-12-15 15:08:16 +01:00
parent 380fef7489
commit 936f27c7a5
2 changed files with 9 additions and 4 deletions

View File

@ -86,12 +86,14 @@ void check_for_client_timeout(){
time_t now;
int i;
if(num_connections > 0){
time(&now);
time(&now);
if(cfg.verbosity >= LOG_DEBUG) syslog(LOG_PRIORITY, "%s @%ld", __func__, now);
if(num_connections > 0){
for(i=0; i<cfg.max_connections; i++){
if(sessions[i] && now - sessions[i]->lasttime >= cfg.smtp_timeout){
syslog(LOG_PRIORITY, "client %s timeout", sessions[i]->remote_host);
syslog(LOG_PRIORITY, "client %s timeout, lasttime: %ld", sessions[i]->remote_host, sessions[i]->lasttime);
tear_down_session(sessions, sessions[i]->slot, &num_connections);
}
}
@ -152,7 +154,7 @@ int main(int argc, char **argv){
return 0;
case 'h' :
default :
default :
usage();
}
}

View File

@ -205,6 +205,9 @@ void handle_data(struct smtp_session *session, char *readbuf, int readlen, struc
p += puflen;
if(puflen > 0){
// Update lasttime if we have a line to process
time(&(session->lasttime));
// pass the puffer to process_data() only if there was an '\n'
// on the line or the puffer does not start with a period
if(session->protocol_state == SMTP_STATE_DATA && (rc == OK || puf[0] != '.')){