[Spice-devel] [PATCH 3/5] vdagent: use virtio-serial, remove pipe usage

Christophe Fergeau cfergeau at redhat.com
Thu Nov 15 05:57:41 PST 2012


This one is quite complicated to review, I didn't look at it very
carefully...

On Wed, Nov 07, 2012 at 03:19:49PM +0200, Arnon Gilboa wrote:
> ---
>  vdagent/vdagent.cpp    |  467 +++++++++++++++++++++++-------------------------
>  vdagent/vdagent.vcproj |   32 +++-
>  2 files changed, 256 insertions(+), 243 deletions(-)
> +void VDAgent::handle_port_out()
> +{
> +    MUTEX_LOCK(_message_mutex);
> +    while (_running && !_message_queue.empty()) {
> +        VDIChunk* chunk = _message_queue.front();
> +        DWORD size = sizeof(VDIChunk) + chunk->hdr.size;
>  
> -        if (size > size_left) {
> +        if (size > _vdi_port->write_ring_free_space()) {
>              break;
>          }
> -        a->_message_queue.pop();
> -        memcpy(a->_pipe_state.write.data + a->_pipe_state.write.end, msg, size);
> -        a->_pipe_state.write.end += size;
> -        size_left -= size;
> -        delete msg;
> -    }
> -    MUTEX_UNLOCK(a->_message_mutex);
> -
> -    if (ps->write.start < ps->write.end) {
> -        if (WriteFileEx(ps->pipe, ps->write.data + ps->write.start,
> -                               ps->write.end - ps->write.start, overlap, write_completion)) {
> -            a->_pending_write = true;
> -        } else {
> -            vd_printf("WriteFileEx() failed: %lu", GetLastError());
> -            a->_running = false;
> +        _message_queue.pop();
> +        if (_vdi_port->ring_write(chunk, size) != size) {
> +            vd_printf("ring_write failed");
> +            _running = false;
> +            return;

This looks like this will be leaking 'chunk'.

Christophe

>          }
> -    } else {
> -        a->_pending_write = false;
> +        delete chunk;
>      }
> -    MUTEX_UNLOCK(a->_write_mutex);
> +    MUTEX_UNLOCK(_message_mutex);
>  }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20121115/573858ef/attachment-0001.pgp>


More information about the Spice-devel mailing list