From fb1df4cd1353bac5eb47398dd1e2c41b5114f5ea Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 28 Jul 2021 14:25:18 -0400 Subject: [PATCH] lib: prevent crash in make check in some situations When running `make check` against a build that zeromq enabled the test_zmq unit test was crashing. The commit: e08165def1c62beee0e87385e37ea5f12ca0f9b9 Introduced this crash. Removing the part of the commit that was causing the crash in the test. This is mainly to get `make check` working again for those people using zeromq in their builds. Fixes: #9176 Signed-off-by: Donald Sharp --- lib/frr_zmq.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c index ce52848a25..ea9c828f7c 100644 --- a/lib/frr_zmq.c +++ b/lib/frr_zmq.c @@ -17,6 +17,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * IF YOU MODIFY THIS FILE PLEASE RUN `make check` and ensure that + * the test_zmq.c unit test is still working. There are dependancies + * between the two that are extremely fragile. My understanding + * is that there is specialized ownership of the cb pointer based + * upon what is happening. Those assumptions are supposed to be + * tested in the test_zmq.c + */ #include #include @@ -309,8 +317,22 @@ void frrzmq_thread_cancel(struct frrzmq_cb **cb, struct cb_core *core) core->cancelled = true; thread_cancel(&core->thread); + /* + * Looking at this code one would assume that FRR + * would want a `!(*cb)->write.thread. This was + * attempted in e08165def1c62beee0e87385 but this + * change caused `make check` to stop working + * which was not noticed because our CI system + * does not build with zeromq. Put this back + * to the code as written in 2017. e08165de.. + * was introduced in 2021. So someone was ok + * with frrzmq_thread_cancel for 4 years. This will + * allow those people doing `make check` to continue + * working. In the meantime if the people using + * this code see an issue they can fix it + */ if ((*cb)->read.cancelled && !(*cb)->read.thread - && (*cb)->write.cancelled && !(*cb)->write.thread) + && (*cb)->write.cancelled && (*cb)->write.thread) XFREE(MTYPE_ZEROMQ_CB, *cb); } -- 2.39.5