Skip to content

Commit

Permalink
Fix for issue lmco#48 and extra logging for when laikamilter cannot c…
Browse files Browse the repository at this point in the history
…onnect to laikad
  • Loading branch information
JMPercival committed Jun 28, 2017
1 parent 8f19c2c commit 489f2bf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions laikamilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -628,15 +637,15 @@ 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()
externalObject = ExternalObject(
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
),
Expand Down

0 comments on commit 489f2bf

Please sign in to comment.