From 19784163be11c1c655b0a643d10ce783d63d16fd Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 15 Jun 2012 11:24:01 +0200 Subject: [PATCH] remove stale files if the smtp connection timed out --- src/session.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/session.c b/src/session.c index 94fc9b59..c3e15bf0 100644 --- a/src/session.c +++ b/src/session.c @@ -83,11 +83,6 @@ int handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){ memcpy(last2buf+prevlen, puf, MAXBUFSIZE); - /*if(sdata.hdr_len == 0){ - sdata.hdr_len = searchStringInBuffer(last2buf, 2*MAXBUFSIZE+1, "\n\r\n", 3); - if(sdata.hdr_len == 0) searchStringInBuffer(last2buf, 2*MAXBUFSIZE+1, "\n\n", 2); - }*/ - pos = searchStringInBuffer(last2buf, 2*MAXBUFSIZE+1, SMTP_CMD_PERIOD, 5); if(pos > 0){ @@ -455,6 +450,15 @@ AFTER_PERIOD: send(new_sd, buf, strlen(buf), 0); if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: sent: %s", sdata.ttmpfile, buf); + if(sdata.fd != -1){ + + syslog(LOG_PRIORITY, "%s: removing stale files: %s, %s", sdata.ttmpfile, sdata.ttmpfile, sdata.tmpframe); + + close(sdata.fd); + unlink(sdata.ttmpfile); + unlink(sdata.tmpframe); + } + goto QUITTING; }