Re: [PATCH spice v2] Add support for clients connecting with the WebSocket protocol.

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

 



Gah, missed a potential problem.

> +int websocket_write(void *opaque, const guchar *buf, int len, guint64 *remainder,
> +         websocket_write_cb_t write_cb)
> +{
> +    guint8 header[WEBSOCKET_MAX_HEADER_SIZE];
> +    int rc;
> +    int header_len;
> +
> +    memset(header, 0, sizeof(header));
> +    header_len = fill_header(header, len);
> +
> +    if (*remainder == 0) {
> +        rc = write_cb(opaque, header, header_len);
> +        if (rc <= 0)
> +            return rc;
> +
> +        if (rc != header_len) {
> +            /* TODO - In theory, we can handle this case.  In practice,
> +                      it does not occur, and does not seem to be worth
> +                      the code complexity */
> +            errno = EPIPE;
> +            return -1;
> +        }
> +    }

Should be an else len = *remainder here, in the case that a previous
write only sent a partial number of bytes.

I'll send a new patch.

> +
> +    rc = write_cb(opaque, buf, len);
> +    if (rc <= 0)
> +        *remainder = len;
> +    else
> +        *remainder = len - rc;
> +    return rc;
> +}

Cheers,

Jeremy
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]