Skip to content

Commit

Permalink
net: lwm2m: Keep user_data between blocks
Browse files Browse the repository at this point in the history
CoAP reply structure user_data should be kept between
ongoing blocks, so that callbacks for LwM2M send continue
to work on blockwise transfers.

Fixes zephyrproject-rtos#64290

Signed-off-by: Seppo Takalo <[email protected]>
  • Loading branch information
SeppoTakalo authored and carlescufi committed Oct 25, 2023
1 parent 3405814 commit cf51345
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions subsys/net/lib/lwm2m/lwm2m_message_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ STATIC int build_msg_block_for_send(struct lwm2m_message *msg, uint16_t block_nu
}
msg->cpkt.hdr_len = msg->body_encode_buffer.hdr_len;
} else {
/* Keep user data between blocks */
void *user_data = msg->reply ? msg->reply->user_data : NULL;

/* reuse message for next block. Copy token from the new query to allow
* CoAP clients to use new token for every query of ongoing transaction
*/
Expand All @@ -323,6 +326,9 @@ STATIC int build_msg_block_for_send(struct lwm2m_message *msg, uint16_t block_nu
LOG_ERR("Unable to init lwm2m message for next block!");
return ret;
}
if (msg->reply) {
msg->reply->user_data = user_data;
}
}

/* copy the options */
Expand Down

0 comments on commit cf51345

Please sign in to comment.