net: lwm2m: cleanup observes when closing context
When a context is closed to a server, we should clean up any existing observes along with it. Otherwise these will try to fire afterward. Signed-off-by: Michael Scott <mike@foundries.io>
This commit is contained in:
parent
35eb7818a7
commit
144ff91670
1 changed files with 14 additions and 1 deletions
|
@ -3824,9 +3824,22 @@ static void lwm2m_engine_service(struct k_work *work)
|
|||
|
||||
int lwm2m_engine_context_close(struct lwm2m_ctx *client_ctx)
|
||||
{
|
||||
struct observe_node *obs, *tmp;
|
||||
sys_snode_t *prev_node = NULL;
|
||||
int sock_fd = client_ctx->sock_fd;
|
||||
|
||||
k_delayed_work_cancel(&client_ctx->retransmit_work);
|
||||
/* Remove observes for this context */
|
||||
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&engine_observer_list,
|
||||
obs, tmp, node) {
|
||||
if (obs->ctx == client_ctx) {
|
||||
sys_slist_remove(&engine_observer_list, prev_node,
|
||||
&obs->node);
|
||||
(void)memset(obs, 0, sizeof(*obs));
|
||||
} else {
|
||||
prev_node = &obs->node;
|
||||
}
|
||||
}
|
||||
|
||||
lwm2m_socket_del(client_ctx);
|
||||
client_ctx->sock_fd = -1;
|
||||
if (sock_fd >= 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue