[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v6 05/11] libxl_qmp: Implementation of libxl__ev_qmp_*



On Thu, Nov 22, 2018 at 08:04:53PM +0100, Marek Marczykowski-Górecki wrote:
> On Mon, Nov 12, 2018 at 04:49:24PM +0000, Anthony PERARD wrote:
> > +static int qmp_ev_callback_readable(libxl__egc *egc,
> > +                                    libxl__ev_qmp *ev, int fd)
> > +{
> > +    EGC_GC;
> > +
> > +    while (1) {
> > +        ssize_t r;
> > +
> > +        /* Check if the buffer still have space, or increase size */
> > +        if (ev->rx_buf_size - ev->rx_buf_used < QMP_RECEIVE_BUFFER_SIZE) {
> > +            ev->rx_buf_size = max(ev->rx_buf_size * 2,
> > +                               (size_t)QMP_RECEIVE_BUFFER_SIZE * 2);
> > +            assert(ev->rx_buf_size <= QMP_MAX_SIZE_RX_BUF);
> > +            if (ev->rx_buf_size > QMP_MAX_SIZE_RX_BUF) {
> > +                LOGD(ERROR, ev->domid,
> > +                     "QMP receive buffer is too big (%ld > %lld)",
> > +                     ev->rx_buf_size, QMP_MAX_SIZE_RX_BUF);
> > +                return ERROR_BUFFERFULL;
> 
> What if you receive multiple messages (events?), but actually a single
> message do fit in a buffer? I think it would be better to stop receiving
> the data in the case of buffer full, but try to find a valid message
> before erroring out.

Yes, that have been taken care of in the v7 that I'm about to send.

The new algorithme is the following:

while true:
    parse(buffer), until no more messages can be found
    read(socket), once
    if EWOULDBLOCK, exit

But thanks for the review.

FYI, that have been talked about in a different thread (because I
mistyped the git-send-email command):
<20181115111510.11628-1-anthony.perard@xxxxxxxxxx>

-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.