Commit cf513451 authored by Seppo Takalo's avatar Seppo Takalo Committed by Carles Cufi
Browse files

net: lwm2m: Keep user_data between blocks



CoAP reply structure user_data should be kept between
ongoing blocks, so that callbacks for LwM2M send continue
to work on blockwise transfers.

Fixes #64290

Signed-off-by: default avatarSeppo Takalo <seppo.takalo@nordicsemi.no>
parent 34058146
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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
		 */
@@ -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 */