On TCP connection failure during session setup, bgp_stop() checks
whether peer->t_read is non-null to know whether or not to unschedule
select() on peer->fd before calling close() on it. Using the API exposed
by thread.c instead of bgpd's wrapper macro BGP_READ_ON() results in
this thread value never being set, which causes bgp_stop() to skip the
cancellation of select() before calling close(). Subsequent calls to
select() on that fd crash the daemon.
Use the macro instead.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
peer = THREAD_ARG(thread);
+ /* This value needs to be unset in order for bgp_read() to be scheduled
+ */
+ BGP_READ_OFF(peer->t_read);
+
/* Check file descriptor. */
slen = sizeof(status);
ret = getsockopt(peer->fd, SOL_SOCKET, SO_ERROR, (void *)&status,
// when the socket becomes ready (or fails to connect),
// bgp_connect_check
// will be called.
- thread_add_read(bm->master, bgp_connect_check, peer, peer->fd);
+ BGP_READ_ON(peer->t_read, bgp_connect_check, peer->fd);
break;
}
return 0;