[Spice-devel] [PATCH 13/17] Add more meaningful syslog reporting
Christophe de Dinechin
christophe at dinechin.org
Fri Feb 16 16:15:43 UTC 2018
From: Christophe de Dinechin <dinechin at redhat.com>
Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
---
src/spice-streaming-agent.cpp | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index c174ea4..faf850c 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -74,10 +74,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;
@@ -118,7 +121,7 @@ struct FormatMessage : Message<StreamMsgFormat, FormatMessage>
}
size_t write(Stream &stream, unsigned w, unsigned h, uint8_t c)
{
- return stream.write_all(this, sizeof(*this));
+ return stream.write_all("FormatMessage", this, sizeof(*this));
}
};
@@ -137,7 +140,8 @@ struct FrameMessage : Message<StreamMsgData, FrameMessage>
}
size_t write(Stream &stream, const void *frame, size_t length)
{
- return stream.write_all(&hdr, sizeof(hdr)) + stream.write_all(frame, length);
+ return stream.write_all("FrameMessage header", &hdr, sizeof(hdr))
+ + stream.write_all("FrameMessage frame", frame, length);
}
};
@@ -173,7 +177,8 @@ struct X11CursorMessage : Message<StreamMsgCursorSet, X11CursorMessage>
}
size_t write(Stream &stream, XFixesCursorImage *cursor)
{
- return stream.write_all(&hdr, sizeof(hdr)) + stream.write_all(pixels.get(), hdr.size);
+ return stream.write_all("X11CursorMessage header", &hdr, sizeof(hdr))
+ + stream.write_all("X11CursorMessage pixels", pixels.get(), hdr.size);
}
void fill_pixels(XFixesCursorImage *cursor)
{
@@ -272,7 +277,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) {
@@ -281,12 +286,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)
More information about the Spice-devel
mailing list