/* 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)
/* 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);
}