examples/cord_ep: Dead lock when (re-)registering in callback function #12884
Labels
Area: network
Area: Networking
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
Type: question
The issue poses a question regarding usage of RIOT
Description
I was using the
cord_ep
example and wanted to automatically (re-)register to an resource directory when thecord_ep_standalone_cb_t
is executed with theCORD_EP_DEREGISTERED
event passed to it.When I call the
register
function insys/net/application_layer/cord/ep/cord_ep.c
though, I produce a dead lock, because the function tries to lock a mutex, which is still locked by the function calling the callback function.Short:
cord_ep_standalone
thread => cord_ep_update =>cord_ep_standalone_signal, => application callback => cord_ep_register.
Possible Solutions:
cord_ep
functions wherecord_ep_standalone_signal
is called)cord_ep_standalone_signal
within cord_ep, because cord_ep_standalone#_reg_runner is actually calling the callback (Currently the callback is triggered twice when an update fails, which is not wanted behavior anyway).Solution 3 is probably the best, because it fixes triggering the callback twice and the dead lock issue as well (Do not forget to remove the timer (
xtimer_remove(&_timer);
) when the update failed, so that the thread will not try to update as long as the device is not (re-)registered).For all the other functions in cord_ep.c that call
cord_eap_standalone_signal
, unlocking the mutex before calling it would be probably the best.Steps to reproduce the issue
/examples/cord_ep
set a callback function (cord_ep_standalone_reg_cb(cord_ep_standalone_cb_t cb)
) and register to a resource directory viacord_ep_register(const sock_udp_ep_t *remote, const char *regif)
inmain
cord_ep_register
Expected results
You can call any function of
cord_ep
in thecord_ep_standalone_cb_t
without producing a dead lock.Actual results
Calling a any function of
cord_ep
in thecord_ep_standalone_cb_t
causes a dead lock.Versions
The text was updated successfully, but these errors were encountered: