diff --git a/laikamilter.py b/laikamilter.py index 44110f9..ff3793e 100755 --- a/laikamilter.py +++ b/laikamilter.py @@ -583,12 +583,21 @@ def close(self): try: self.client.close() except: - self.logger.writeLog(syslog.LOG_ERR, self.uuid+" ERROR attempting to close ZMQ context") + #If client in not connected check your laikamilter config + if self.client == None: + self.logger.writeLog(syslog.LOG_ERR, "ERROR cannot close non-connected client in ZMQ context") + else: + self.logger.writeLog(syslog.LOG_ERR, "ERROR attempting to close ZMQ context") #public function to get flags from si-scan def zmqGetFlagswithRetry(self, numRetries, milterContext): sendResponse = self._zmqGetFlags(numRetries, milterContext) + if sendResponse == -1: + self.logger.writeLog(syslog.LOG_ERR, \ + "ERROR Laikamilter could not connect to laikad servers:"\ + + str(milterContext.milterConfig.servers) + ) def _getNextScanServer(self): @@ -628,7 +637,6 @@ def _zmqGetFlags(self, numRetries, milterContext): def _zmqSendBuffer(self, milterContext,numRetries, REQUEST_TIMEOUT,SERVER_ENDPOINT): gotResponseFromScanner=-1 self.client = Client(SERVER_ENDPOINT) - log = milterContext.uuid+" Sending "+ str(milterContext.qid)+" to "+ SERVER_ENDPOINT self.logger.writeLog(syslog.LOG_DEBUG, "%s"%(str(log))) myhostname = socket.gethostname() @@ -636,7 +644,8 @@ def _zmqSendBuffer(self, milterContext,numRetries, REQUEST_TIMEOUT,SERVER_ENDPOI buffer=milterContext.fileBuffer, externalVars=ExternalVars( filename=milterContext.archiveFileName, - source=milterContext.milterConfig.milterName+"-"+str(myhostname[:myhostname.index(".")]), + source=milterContext.milterConfig.milterName+"-"+ \ + (str(myhostname[:myhostname.index(".")]) if "." in myhostname else str(myhostname)), ephID=milterContext.qid, uniqID=milterContext.messageID ),