No new message can be enqueued if this brings the total queue length of
that client over UBUS_CLIENT_MAX_TXQ_LEN.
Set UBUS_CLIENT_MAX_TXQ_LEN to UBUS_MAX_MSGLEN, i.e. 1MB. This limit
should be plenty for any practical use case.
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
{
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;
ubl->msg = ubus_msg_ref(ub);
list_add_tail(&cl->tx_queue, &ubl->list);
+ cl->txq_len += ub->len;
}
/* takes the msgbuf reference */
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);
#include "ubusd_acl.h"
#define UBUS_OBJ_HASH_BITS 4
+#define UBUS_CLIENT_MAX_TXQ_LEN UBUS_MAX_MSGLEN
extern struct blob_buf b;
struct list_head tx_queue;
unsigned int txq_ofs;
+ unsigned int txq_len;
struct ubus_msg_buf *pending_msg;
struct ubus_msg_buf *retmsg;
}
cl->txq_ofs += written;
+ cl->txq_len -= written;
if (cl->txq_ofs < ub->len + sizeof(ub->hdr))
break;