ubusd: do not call socket callback from ubus_msg_send
authorFelix Fietkau <[email protected]>
Wed, 2 Jul 2025 17:05:08 +0000 (19:05 +0200)
committerFelix Fietkau <[email protected]>
Wed, 2 Jul 2025 17:06:06 +0000 (19:06 +0200)
Fixes a crash.

Fixes: 713e9d19b2b6 ("ubusd: retry write on EINTR")
Signed-off-by: Felix Fietkau <[email protected]>
ubusd.c

diff --git a/ubusd.c b/ubusd.c
index 70ffffbaa37012fbe0aea140ea52e0d00aac2b85..13557d142432d10ece5c7c04c9928a82b7dd7013 100644 (file)
--- a/ubusd.c
+++ b/ubusd.c
@@ -161,13 +161,12 @@ static void ubus_msg_enqueue(struct ubus_client *cl, struct ubus_msg_buf *ub)
 /* takes the msgbuf reference */
 void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub)
 {
-       bool write_direct = list_empty(&cl->tx_queue);
        ssize_t written;
 
        if (ub->hdr.type != UBUS_MSG_MONITOR)
                ubusd_monitor_message(cl, ub, true);
 
-       if (write_direct) {
+       if (list_empty(&cl->tx_queue)) {
                written = ubus_msg_writev(cl->sock.fd, ub, 0);
 
                if (written < 0)
@@ -184,7 +183,4 @@ void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub)
        }
 
        ubus_msg_enqueue(cl, ub);
-
-       if (write_direct)
-               cl->sock.cb(&cl->sock, ULOOP_WRITE);
 }