Fixed tear_down_session()

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2021-02-09 08:55:47 +01:00
parent 9dbfbb74af
commit 0f2657275c

View File

@ -134,7 +134,12 @@ void free_smtp_session(struct smtp_session *session){
void tear_down_session(struct smtp_session **sessions, int slot, int *num_connections){ void tear_down_session(struct smtp_session **sessions, int slot, int *num_connections){
syslog(LOG_PRIORITY, "disconnected from %s on fd=%d (%d active connections)", sessions[slot]->remote_host, sessions[slot]->net.socket, (*num_connections)-1); if(sessions[slot] == NULL){
syslog(LOG_PRIORITY, "session already torn down, slot=%d (%d active connections)", slot, *num_connections);
return;
}
syslog(LOG_PRIORITY, "disconnected from %s on fd=%d, slot=%d (%d active connections)", sessions[slot]->remote_host, sessions[slot]->net.socket, slot, (*num_connections)-1);
close(sessions[slot]->net.socket); close(sessions[slot]->net.socket);
@ -148,7 +153,7 @@ void tear_down_session(struct smtp_session **sessions, int slot, int *num_connec
free_smtp_session(sessions[slot]); free_smtp_session(sessions[slot]);
sessions[slot] = NULL; sessions[slot] = NULL;
(*num_connections)--; if(*num_connections > 0) (*num_connections)--;
} }