diff options
| author | Felix Fietkau | 2025-07-01 18:37:52 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-07-01 18:39:00 +0000 |
| commit | b1b783c7474269593b23ba01be8a86eb36e3471a (patch) | |
| tree | 7872b809adef94ae07444b73ac2336665a89f60c | |
| parent | 8bb523ab20e06f686a07c5f82e8f8534d4228b9f (diff) | |
| download | ubus-b1b783c7474269593b23ba01be8a86eb36e3471a.tar.gz | |
ubusd: add another tx attempt on enqueueing the first message for a client
Make sure that the write buffer is indeed full before waiting for the uloop
event.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | ubusd.c | 7 | ||||
| -rw-r--r-- | ubusd_main.c | 2 |
2 files changed, 7 insertions, 2 deletions
@@ -161,12 +161,13 @@ 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 (list_empty(&cl->tx_queue)) { + if (write_direct) { written = ubus_msg_writev(cl->sock.fd, ub, 0); if (written < 0) @@ -181,5 +182,9 @@ void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub) /* get an event once we can write to the socket again */ uloop_fd_add(&cl->sock, ULOOP_READ | ULOOP_WRITE | ULOOP_EDGE_TRIGGER); } + ubus_msg_enqueue(cl, ub); + + if (write_direct) + cl->sock.cb(&cl->sock, ULOOP_WRITE); } diff --git a/ubusd_main.c b/ubusd_main.c index 8422d63..0e4c6d8 100644 --- a/ubusd_main.c +++ b/ubusd_main.c @@ -101,7 +101,7 @@ retry_writev: cl->txq_ofs += written; cl->txq_len -= written; if (cl->txq_ofs < ub->len + sizeof(ub->hdr)) - break; + goto retry_writev; cl->txq_ofs = 0; ubus_msg_list_free(ubl); |