2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Don't increment network error stats on UV_EOF

When networking statistics was added to the netmgr (in commit
5234a8e00a), two lines were added that
increment the 'STATID_RECVFAIL' statistic: One if 'uv_read_start'
fails and one at the end of the 'read_cb'.  The latter happens
if 'nread < 0'.

According to the libuv documentation, I/O read callbacks (such as for
files and sockets) are passed a parameter 'nread'. If 'nread' is less
than 0, there was an error and 'UV_EOF' is the end of file error, which
you may want to handle differently.

In other words, we should not treat EOF as a RECVFAIL error.
This commit is contained in:
Matthijs Mekking
2020-10-20 10:57:16 +02:00
parent a63ac933bb
commit 6c5ff94218
4 changed files with 35 additions and 1 deletions

View File

@@ -803,8 +803,10 @@ read_cb(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) {
* This might happen if the inner socket is closing. It means that
* it's detached, so the socket will be closed.
*/
if (cb != NULL) {
if (nread != UV_EOF) {
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_RECVFAIL]);
}
if (cb != NULL) {
isc__nmsocket_clearcb(sock);
cb(sock->statichandle, ISC_R_EOF, NULL, cbarg);
}