From e7aa081d43ec22b3513cefcb5c7c64dbc68c8021 Mon Sep 17 00:00:00 2001 From: kanoi Date: Sun, 12 Jul 2015 22:29:30 +1000 Subject: [PATCH] libckpool - report errno with _write_length failure --- src/libckpool.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libckpool.c b/src/libckpool.c index 50358ab9..745eba49 100644 --- a/src/libckpool.c +++ b/src/libckpool.c @@ -1005,7 +1005,7 @@ out: int _write_length(int sockd, const void *buf, int len, const char *file, const char *func, const int line) { - int ret, ofs = 0; + int ret, ofs = 0, ern; if (unlikely(len < 1)) { LOGWARNING("Invalid write length of %d requested in write_length from %s %s:%d", @@ -1013,6 +1013,7 @@ int _write_length(int sockd, const void *buf, int len, const char *file, const c return -1; } if (unlikely(sockd < 0)) { + ern = errno; LOGWARNING("Attempt to write to invalidated sock in write_length from %s %s:%d", file, func, line); return -1; @@ -1020,8 +1021,9 @@ int _write_length(int sockd, const void *buf, int len, const char *file, const c while (len) { ret = write(sockd, buf + ofs, len); if (unlikely(ret < 0)) { - LOGERR("Failed to write %d bytes in write_length from %s %s:%d", - len, file, func, line); + ern = errno; + LOGERR("Failed to write %d bytes in write_length (%d) from %s %s:%d", + len, ern, file, func, line); return -1; } ofs += ret;