Skip to content

Commit

Permalink
zbus: vded: msg_sub: Improve channel ref copy
Browse files Browse the repository at this point in the history
The VDED was adding the channel information per clone. But it could be
done in the original buffer. This commit fixes that by adding the
channel information to the original buffer and not for each clone. As a
result, we have a more straightforward VDED execution with fewer copies.

Signed-off-by: Rodrigo Peixoto <[email protected]>
  • Loading branch information
rodrigopex authored and dleach02 committed Jun 9, 2024
1 parent 8136f74 commit 453ab8a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion subsys/zbus/zbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static inline int _zbus_notify_observer(const struct zbus_channel *chan,
if (cloned_buf == NULL) {
return -ENOMEM;
}
memcpy(net_buf_user_data(cloned_buf), &chan, sizeof(struct zbus_channel *));

net_buf_put(obs->message_fifo, cloned_buf);

Expand Down Expand Up @@ -136,6 +135,8 @@ static inline int _zbus_vded_exec(const struct zbus_channel *chan, k_timepoint_t
_ZBUS_ASSERT(buf != NULL, "net_buf zbus_msg_subscribers_pool is "
"unavailable or heap is full");

memcpy(net_buf_user_data(buf), &chan, sizeof(struct zbus_channel *));

net_buf_add_mem(buf, zbus_chan_msg(chan), zbus_chan_msg_size(chan));
#endif /* CONFIG_ZBUS_MSG_SUBSCRIBER */

Expand Down

0 comments on commit 453ab8a

Please sign in to comment.