mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-01-12 06:10:12 +01:00
smtp session fixes
Change-Id: I2e1b7dac87d5513e3dfefe4823dcaf43167f1d64 Signed-off-by: SJ <sj@acts.hu>
This commit is contained in:
parent
7c3d659194
commit
376b0345e1
@ -299,7 +299,9 @@ int main(int argc, char **argv){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(done){
|
/* Don't wait until the remote client closes the connection after he sent the QUIT command */
|
||||||
|
|
||||||
|
if(done || session->protocol_state == SMTP_STATE_FINISHED){
|
||||||
tear_down_session(sessions, session->slot, &num_connections);
|
tear_down_session(sessions, session->slot, &num_connections);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <netdb.h>
|
||||||
#include <piler.h>
|
#include <piler.h>
|
||||||
|
|
||||||
|
|
||||||
@ -100,6 +101,10 @@ struct smtp_session *get_session_by_socket(struct smtp_session **sessions, int m
|
|||||||
|
|
||||||
|
|
||||||
void init_smtp_session(struct smtp_session *session, int slot, int sd, struct __config *cfg){
|
void init_smtp_session(struct smtp_session *session, int slot, int sd, struct __config *cfg){
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
socklen_t addr_size = sizeof(struct sockaddr_in);
|
||||||
|
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
|
||||||
|
|
||||||
session->slot = slot;
|
session->slot = slot;
|
||||||
|
|
||||||
session->socket = sd;
|
session->socket = sd;
|
||||||
@ -119,6 +124,11 @@ void init_smtp_session(struct smtp_session *session, int slot, int sd, struct __
|
|||||||
reset_bdat_counters(session);
|
reset_bdat_counters(session);
|
||||||
|
|
||||||
time(&(session->lasttime));
|
time(&(session->lasttime));
|
||||||
|
|
||||||
|
if(getpeername(sd, (struct sockaddr *)&addr, &addr_size) == 0 &&
|
||||||
|
getnameinfo((struct sockaddr *)&addr, addr_size, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0){
|
||||||
|
snprintf(session->remote_host, INET6_ADDRSTRLEN-1, "%s", hbuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -211,4 +221,3 @@ void handle_data(struct smtp_session *session, char *readbuf, int readlen){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user