Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: prevent crash in make check in some situations #9211

Merged
merged 1 commit into from
Aug 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion lib/frr_zmq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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);
}

Expand Down