From 1a68d37a3667dc6b1da81af70bbf578e82d6f632 Mon Sep 17 00:00:00 2001 From: SJ Date: Sat, 26 Nov 2016 11:49:08 +0100 Subject: [PATCH] minor fixes Change-Id: I16d16df9db05219fefd918d2c977e6ee6cc9f5f0 Signed-off-by: SJ --- init.d/rc.piler.in | 12 ++++++++++++ src/piler-smtp.c | 2 +- src/session.c | 1 - 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/init.d/rc.piler.in b/init.d/rc.piler.in index d0ef02bd..f756b45b 100644 --- a/init.d/rc.piler.in +++ b/init.d/rc.piler.in @@ -17,8 +17,12 @@ NAME=piler OPTIONS="" PID_FILE=`SBINDIR/pilerconf $OPTIONS -q pidfile | cut -f2 -d=` PID_NUMBER=`test -f ${PID_FILE} && cat ${PID_FILE}` +PILER_SMTP_PID=$(ps uaxw | grep -w piler-smtp | grep -v grep | awk '{print $2}') start() { + echo "starting piler-smtp . . . " + SBINDIR/piler-smtp -d + echo "starting $NAME . . ." SBINDIR/piler -d $OPTIONS } @@ -26,10 +30,18 @@ start() { stop() { echo "stopping $NAME" kill ${PID_NUMBER} + + if [ $PILER_SMTP_PID != '' ]; then echo "stopping piler-smtp"; kill $PILER_SMTP_PID; fi } check_status(){ test -f /proc/${PID_NUMBER}/status + + if [ "${PILER_SMTP_PID}" != '' ]; then + echo "piler-smtp is running, pid: ${PILER_SMTP_PID}"; + else + echo "piler-smtp is NOT running"; + fi } case "$1" in diff --git a/src/piler-smtp.c b/src/piler-smtp.c index b61e9903..9ed2d98c 100644 --- a/src/piler-smtp.c +++ b/src/piler-smtp.c @@ -272,7 +272,7 @@ int main(int argc, char **argv){ else readlen = read(events[i].data.fd, (char*)&readbuf[0], sizeof(readbuf)-1); - if(cfg.verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "got %ld bytes to read", readlen); + if(cfg.verbosity >= _LOG_DEBUG && readlen > 0) syslog(LOG_PRIORITY, "got %ld bytes to read", readlen); if(readlen == -1){ /* If errno == EAGAIN, that means we have read all data. So go back to the main loop. */ diff --git a/src/session.c b/src/session.c index a7cc8497..dda703a5 100644 --- a/src/session.c +++ b/src/session.c @@ -174,7 +174,6 @@ void handle_data(struct smtp_session *session, char *readbuf, int readlen){ // process other SMTP commands else { - //printf("len=%d, buf=*%s*\n\n\n", readlen, readbuf); if(session->buflen > 0){ snprintf(puf, sizeof(puf)-1, "%s%s", session->buf, readbuf);