summaryrefslogtreecommitdiffstats
path: root/lib/frr_zmq.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-07-28 20:25:18 +0200
committerDonald Sharp <sharpd@nvidia.com>2021-07-28 20:41:46 +0200
commitfb1df4cd1353bac5eb47398dd1e2c41b5114f5ea (patch)
tree97af5783c4a45f37ee0697e8432ec1070ec9b14e /lib/frr_zmq.c
parentMerge pull request #9104 from idryzhov/topotest-multiline (diff)
downloadfrr-fb1df4cd1353bac5eb47398dd1e2c41b5114f5ea.tar.xz
frr-fb1df4cd1353bac5eb47398dd1e2c41b5114f5ea.zip
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 <sharpd@nvidia.com>
Diffstat (limited to '')
-rw-r--r--lib/frr_zmq.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c
index ce52848a2..ea9c828f7 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 <zebra.h>
#include <zmq.h>
@@ -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);
}