From e02813b2cc62f672127360e7515017c02df7af18 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 5 Jul 2017 16:20:51 +0300 Subject: ubusd: don't free messages in ubus_send_msg() anymore This makes it clear that `ubus_msg_send()` is only about sending and queue-ing messages, and has nothing to do with free-ing. It can be a bit misleading/confusing when trying to go through the code and make assumptions about whether a buffer is free'd in ubus_send_msg(), or is free'd outside. In `ubusd_proto_receive_message()` the `ubus_msg_free()` is now called before the `if (ret == -1)` check. That way, all callbacks will have their messages free'd, which is what's desired, but confusing, because: * ubusd_handle_invoke() called ubus_msg_free() before returning -1 * ubusd_handle_notify() called ubus_msg_free() before returning -1 * ubusd_handle_response() called ubus_msg_send(,,free=true) before returning -1 * ubus_msg_send() would call ubus_msg_send(,,free=false) * all other callback callers would `ubus_msg_send(,,free=true)` (free the buffers in ubus_msg_send() ) In all other places, where `ubus_msg_send(,,free=true)` an explicit `ubus_msg_free()` was added. Signed-off-by: Alexandru Ardelean --- ubusd_monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ubusd_monitor.c') diff --git a/ubusd_monitor.c b/ubusd_monitor.c index 82d0333..a192206 100644 --- a/ubusd_monitor.c +++ b/ubusd_monitor.c @@ -76,7 +76,8 @@ ubusd_monitor_message(struct ubus_client *cl, struct ubus_msg_buf *ub, bool send ub = ubus_msg_new(mb.head, blob_raw_len(mb.head), true); ub->hdr.type = UBUS_MSG_MONITOR; ub->hdr.seq = ++m->seq; - ubus_msg_send(m->cl, ub, true); + ubus_msg_send(m->cl, ub); + ubus_msg_free(ub); } } -- cgit v1.2.1