From 30965ba950a13f4c6ff256d6a7e030826a2a28a0 Mon Sep 17 00:00:00 2001 From: ahrenholz Date: Wed, 4 Sep 2013 17:03:34 +0000 Subject: [PATCH] (Boeing r1764) added Broker.handlerawmsg() helper to invoke handlemsg() using packed bytes --- daemon/core/broker.py | 8 ++++++++ daemon/core/session.py | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/daemon/core/broker.py b/daemon/core/broker.py index b62536b8..5c6c6cb6 100644 --- a/daemon/core/broker.py +++ b/daemon/core/broker.py @@ -779,6 +779,14 @@ class CoreBroker(ConfigurableManager): self.session._handlerslock.release() return host + def handlerawmsg(self, msg): + ''' Helper to invoke handlemsg() using raw (packed) message bytes. + ''' + hdr = msg[:coreapi.CoreMessage.hdrsiz] + msgtype, flags, msglen = coreapi.CoreMessage.unpackhdr(hdr) + msgcls = coreapi.msg_class(msgtype) + return self.handlemsg(msgcls(flags, hdr, msg[coreapi.CoreMessage.hdrsiz:])) + def forwardmsg(self, msg, serverlist, handle_locally): ''' Forward API message to all servers in serverlist; if an empty host/port is encountered, set the handle_locally flag. Returns the diff --git a/daemon/core/session.py b/daemon/core/session.py index 32072682..f0608e45 100644 --- a/daemon/core/session.py +++ b/daemon/core/session.py @@ -246,10 +246,7 @@ class Session(object): except Exception, e: self.warn("Error sending Event Message: %s" % e) # also inform slave servers - coremsg = coreapi.CoreEventMessage(0, - msg[:coreapi.CoreMessage.hdrsiz], - msg[coreapi.CoreMessage.hdrsiz:]) - tmp = self.broker.handlemsg(coremsg) + tmp = self.broker.handlerawmsg(msg) return replies