]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix potential deadlock 1508/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 1 Dec 2017 18:41:27 +0000 (13:41 -0500)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 1 Dec 2017 18:41:27 +0000 (13:41 -0500)
With the way things are set up, this bit of code would never actually
cause a deadlock, but would be highly likely in the future.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_packet.c

index e111dd785fd4bf39d84628c50c1441c6403c3ddc..4b018aef4d54eb0011d8e17e6c26026fd39801ed 100644 (file)
@@ -556,12 +556,14 @@ static int bgp_write_notify(struct peer *peer)
        {
                /* There should be at least one packet. */
                s = stream_fifo_pop(peer->obuf);
-               if (!s)
-                       return 0;
-               assert(stream_get_endp(s) >= BGP_HEADER_SIZE);
        }
        pthread_mutex_unlock(&peer->io_mtx);
 
+       if (!s)
+               return 0;
+
+       assert(stream_get_endp(s) >= BGP_HEADER_SIZE);
+
        /* Stop collecting data within the socket */
        sockopt_cork(peer->fd, 0);