summaryrefslogtreecommitdiff
path: root/ubusd_monitor.c
diff options
context:
space:
mode:
authorAlexandru Ardelean <ardeleanalex@gmail.com>2017-07-05 16:20:51 +0300
committerFelix Fietkau <nbd@nbd.name>2017-11-13 09:55:19 +0100
commite02813b2cc62f672127360e7515017c02df7af18 (patch)
tree6a3ee7956b20785131b34e5075b113e165de4abd /ubusd_monitor.c
parent6d1ea6c33d321e4840b05986b6ce8e214bd1ba3a (diff)
downloadubus-e02813b2cc62f672127360e7515017c02df7af18.tar.gz
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 <ardeleanalex@gmail.com>
Diffstat (limited to 'ubusd_monitor.c')
-rw-r--r--ubusd_monitor.c3
1 files changed, 2 insertions, 1 deletions
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);
}
}