summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVictor Orlikowski <vjo@duke.edu>2016-08-02 11:02:31 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-08-02 11:02:31 +0900
commit12d6584bee4aca4a5bf2e93e3b8eca43cae76d0d (patch)
tree79150f2011579ee38e88bf50c96ac59ca6aedf4d
parent9ee265ab4535d6995d99cbee6bcfc344be411e77 (diff)
Ensure that send() and send_msg() in controller return status to calling applications
When a Datapath disconnects, an application may not know about it until it attempts to send a message to that Datapath. Ryu's core will detect the failure to send, and will close the Datapath object - but has no way of letting the application know that it did so. With this patch, send_msg() returns True or False, depending on whether the message that the application was trying to send was able to be enqueued to send via a given Datapath object. If the Datapath.send_msg() returns False, the calling application can thereby determine that the Datapath is no longer valid, and should clean up any references it has to it. Existing applications may choose to ignore the return value, and nothing breaks. I have patched one utility method that uses send_msg(), since it was not marked as deprecated. All utility methods marked as deprecated, I have not altered. Signed-off-by: Victor J. Orlikowski <vjo@duke.edu> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/controller/controller.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py
index 54fb1c95..cf9deb99 100644
--- a/ryu/controller/controller.py
+++ b/ryu/controller/controller.py
@@ -319,6 +319,7 @@ class Datapath(ofproto_protocol.ProtocolDesc):
if not msg_enqueued:
LOG.debug('Datapath in process of terminating; send() to %s discarded.',
self.address)
+ return msg_enqueued
def set_xid(self, msg):
self.xid += 1
@@ -332,7 +333,7 @@ class Datapath(ofproto_protocol.ProtocolDesc):
self.set_xid(msg)
msg.serialize()
# LOG.debug('send_msg %s', msg)
- self.send(msg.buf)
+ return self.send(msg.buf)
def _echo_request_loop(self):
if not self.max_unreplied_echo_requests:
@@ -418,7 +419,7 @@ class Datapath(ofproto_protocol.ProtocolDesc):
def send_barrier(self):
barrier_request = self.ofproto_parser.OFPBarrierRequest(self)
- self.send_msg(barrier_request)
+ return self.send_msg(barrier_request)
def send_nxt_set_flow_format(self, flow_format):
assert (flow_format == ofproto_v1_0.NXFF_OPENFLOW10 or