Christophe Fergeau wrote:
This one is quite complicated to review, I didn't look at it very
carefully...
will be nice if you give it another 5 mins...
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
10x, although we exit in this case i have no idea where did that
"return" came from ;)
}
- } else {
- a->_pending_write = false;
+ delete chunk;
}
- MUTEX_UNLOCK(a->_write_mutex);
+ MUTEX_UNLOCK(_message_mutex);
}
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel