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 <[email protected]> --- diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py index 54fb1c9..cf9deb9 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 Best, Victor -- Victor J. Orlikowski <> vjo@[cs.]duke.edu
send_msg_return.patch
Description: send_msg_return.patch
------------------------------------------------------------------------------
_______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
