On Tue, 6 May 2014 09:10:26 +0000 ISHIDA Wataru <[email protected]> wrote:
> BGP session can be closed by sending inappropriate messages. > So touching socket by get_peername() after sending messages may cause an > exception. Though we can handle this by try..exception, I fixed to simply > call get_peername() before sending messages because session disconnection by > sending messages is an ordinary procedure and not an exception(the peer will > send notification before disconnection). > > Signed-off-by: ISHIDA Wataru <[email protected]> > --- > ryu/services/protocols/bgp/speaker.py | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/ryu/services/protocols/bgp/speaker.py > b/ryu/services/protocols/bgp/speaker.py > index a0e2ae5..dc828d1 100644 > --- a/ryu/services/protocols/bgp/speaker.py > +++ b/ryu/services/protocols/bgp/speaker.py > @@ -371,15 +371,18 @@ class BgpProtocol(Protocol, Activity): > raise BgpProtocolException('Tried to send message to peer when ' > 'this protocol instance is not > started' > ' or is no longer is started state.') > + # get peername before senging msg because sending msg can occur > + # conncetion lost > + peername = self.get_peername() > self._socket.sendall(msg.serialize()) Is there possibility that a connection is closed right after get_peername and an exception happens? ------------------------------------------------------------------------------ Is your legacy SCM system holding you back? Join Perforce May 7 to find out: • 3 signs your SCM is hindering your productivity • Requirements for releasing software faster • Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
