summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 686bd66)
raw | patch | inline | side by side (parent: 686bd66)
author | Pavel Rochnyack <pavel2000@ngs.ru> | |
Mon, 31 Jul 2017 05:21:24 +0000 (12:21 +0700) | ||
committer | Pavel Rochnyack <pavel2000@ngs.ru> | |
Tue, 26 Sep 2017 20:05:33 +0000 (03:05 +0700) |
According to POSIX, errno is set only if 'recv()' returns -1.
When connection has been closed, 'recv()' returns 0 and errno left untouched.
For functions which check errno value after 'swrite()', errno now is set to ECONNRESET,
so they produce correct message 'Connection reset by peer'.
When connection has been closed, 'recv()' returns 0 and errno left untouched.
For functions which check errno value after 'swrite()', errno now is set to ECONNRESET,
so they produce correct message 'Connection reset by peer'.
src/daemon/common.c | patch | blob | history |
diff --git a/src/daemon/common.c b/src/daemon/common.c
index 3ae61d8592e5df6b3f42986f0e1131ef5682ace3..6c856a6b0c7ea6fbdc543974979601e9e070c8bf 100644 (file)
--- a/src/daemon/common.c
+++ b/src/daemon/common.c
if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) {
/* if recv returns zero (even though poll() said there is data to be
* read), that means the connection has been closed */
- return errno ? errno : -1;
+ errno = ECONNRESET;
+ return -1;
}
}