X-Git-Url: http://git.openwrt.org/?p=project%2Fubus.git;a=blobdiff_plain;f=ubusd.c;fp=ubusd.c;h=0e1b0c961b0688b565fda9272ae93d1a378e26fb;hp=c324c704a74f7494407f1240f3a8ccfbc2f084cb;hb=c736e47f3e2ad8f895306e9917f7bd6143fd29d9;hpb=4becbd67de5867ec32a53cb15566a6ef505f4619 diff --git a/ubusd.c b/ubusd.c index c324c70..0e1b0c9 100644 --- a/ubusd.c +++ b/ubusd.c @@ -144,6 +144,9 @@ static void ubus_msg_enqueue(struct ubus_client *cl, struct ubus_msg_buf *ub) { struct ubus_msg_buf_list *ubl; + if (cl->txq_len + ub->len > UBUS_CLIENT_MAX_TXQ_LEN) + return; + ubl = calloc(1, sizeof(struct ubus_msg_buf_list)); if (!ubl) return; @@ -152,6 +155,7 @@ static void ubus_msg_enqueue(struct ubus_client *cl, struct ubus_msg_buf *ub) ubl->msg = ubus_msg_ref(ub); list_add_tail(&cl->tx_queue, &ubl->list); + cl->txq_len += ub->len; } /* takes the msgbuf reference */ @@ -172,6 +176,7 @@ void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub) return; cl->txq_ofs = written; + cl->txq_len = -written; /* get an event once we can write to the socket again */ uloop_fd_add(&cl->sock, ULOOP_READ | ULOOP_WRITE | ULOOP_EDGE_TRIGGER);