Ive been browsing the code in ubusd.c and I've seen something that appears to be a bug.
In function client_cb there is this bit of code...
/* first try to tx more pending data */
while ((ub = ubus_msg_head(cl))) {
int written;
written = ubus_msg_writev(sock->fd, ub, cl->txq_ofs);
if (written < 0) {
switch(errno) {
case EINTR:
case EAGAIN:
break;
default:
goto disconnect;
}
break;
}
cl->txq_ofs += written;
if (cl->txq_ofs < ub->len + sizeof(ub->hdr))
break;
ubus_msg_dequeue(cl);
}
In the case where errno is EAGAIN or EINTR, written will be <0 and the code will then add its value to cl->txq_ofs.
Shouldn't the code only update cl->txq_ofs etc when written is > 0? Isn't the usual thing to do when errno is EAGAIN/EINTR retry the write call?
Apologies if I've missed something obvious here.