From: Christophe de Dinechin <dinechin@xxxxxxxxxx> Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx> --- src/spice-streaming-agent.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp index 85d055b..5fef102 100644 --- a/src/spice-streaming-agent.cpp +++ b/src/spice-streaming-agent.cpp @@ -77,10 +77,13 @@ public: std::lock_guard<std::mutex> stream_guard(mutex); size_t expected = message.size(payload...); size_t written = message.write(*this, payload...); - return written == expected; + bool result = written == expected; + if (!result) + syslog(LOG_WARNING, "sent only %zu bytes out of %zu", written, expected); + return result; } - size_t write_all(const void *buf, const size_t len); + size_t write_all(const char *what, const void *buf, const size_t len); private: int streamfd = -1; @@ -122,7 +125,7 @@ struct FormatMessage : Message<StreamMsgFormat, FormatMessage> } size_t write(Stream &stream, unsigned w, unsigned h, uint8_t c) { - return stream.write_all(this, sizeof(message_t)); + return stream.write_all("FormatMessage", this, sizeof(message_t)); } }; @@ -141,8 +144,8 @@ struct FrameMessage : Message<StreamMsgData, FrameMessage> } size_t write(Stream &stream, const void *frame, size_t length) { - return stream.write_all(this, sizeof(message_t)) - + stream.write_all(frame, length); + return stream.write_all("FrameMessage header", this, sizeof(message_t)) + + stream.write_all("FrameMessage frame", frame, length); } }; @@ -179,8 +182,8 @@ struct X11CursorMessage : Message<StreamMsgCursorSet, X11CursorMessage> size_t write(Stream &stream, XFixesCursorImage *cursor) { unsigned pixel_size = pixel_count(cursor) * sizeof(uint32_t); - return stream.write_all(this, sizeof(message_t)) - + stream.write_all(pixels.get(), pixel_size); + return stream.write_all("X11CursorMessage header", this, sizeof(message_t)) + + stream.write_all("X11CursorMessage pixels", pixels.get(), pixel_size); } void fill_pixels(XFixesCursorImage *cursor) { @@ -316,7 +319,7 @@ int Stream::read_command(bool blocking) return 1; } -size_t Stream::write_all(const void *buf, const size_t len) +size_t Stream::write_all(const char *what, const void *buf, const size_t len) { size_t written = 0; while (written < len) { @@ -325,12 +328,12 @@ size_t Stream::write_all(const void *buf, const size_t len) if (errno == EINTR) { continue; } - syslog(LOG_ERR, "write failed - %m"); + syslog(LOG_ERR, "write %s failed - %m", what); return l; } written += l; } - syslog(LOG_DEBUG, "write_all -- %u bytes written\n", (unsigned)written); + syslog(LOG_DEBUG, "write %s -- %u bytes written\n", what, (unsigned)written); return written; } -- 2.13.5 (Apple Git-94) _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel