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
LwM2M lwm2m_rd_client_stop() not working when called during bootstrapping/registration #37170
Comments
I was not able to reproduce with qemu, but I can imagine that the issue could occur with slower platforms (I'm not sure what modem this is, but looking at the timestamps, it takes its time for processing What I think could happen in this case, is that when I think the most reasonable way to handle this would be to add a mutex protection to the LwM2M state machine. The LwM2M engine should simply lock the mutex when processing Alternatively we could add some extra logic to the fault handling routines, to check if the "IDLE" state wasn't set during the processing, but I think the mutex approach is a much cleaner solution. |
Thanks @rlubos for the thorough evaluation and trying to reproduce it. The mutex solution indeed sounds nice. If you want, I can give it a shot. |
That would be nice, thanks. It should be a simple change, it should be enough to add a mutex lock/unlock at the beginning/end of the aforementioned functions (unless I miss something). |
Looked at it, and indeed it would be simple. There is even TLDR: I did notice that the state is only set using
Personally, I think option 2 is safest as it doesn't lean on the assumption that most mutations are done by a single thread running What do you think? Background: Additionally, the setter and getter are used in the |
I'm afraid that adding mutex lock in It might be needed however to add the mutex also for the |
A mutex is used to syncrhonize the start, stop and service() functions of the RD client. Previously it could happen that while service() was working on e.g. bootstrapping, a stop() call by another thread would close the socket. Then the bootstrapping process would detect it as a network error, and restart the process. Fixes #37170. Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
Describe the bug
When external logic calls
lwm2m_rd_client_stop()
while the client is already bootstrapping or registering, it often (not always) does not work:To Reproduce
See above log, but in short:
lwm2m_rd_client_stop()
while the RD client is still bootstrapping/registering (preferably ASAP)sm_do_network_error()
Expected behavior
The RD client to stop completely (and remain so until explicitly started again)
Impact
Data communication where we do not expect and want it. More power consumption etc.
The text was updated successfully, but these errors were encountered: