diff options
author | Andrei Belov <defan@nginx.com> | 2020-08-13 19:28:27 +0300 |
---|---|---|
committer | Andrei Belov <defan@nginx.com> | 2020-08-13 19:28:27 +0300 |
commit | aff76e4f90b4e948c327ce2b021dc3203c33cbcd (patch) | |
tree | 5bd6ac3aa92683777548472984c209bf26d8a971 /src/nxt_socket.c | |
parent | 04ce9f997e0e49e57ce4b5fc4aa98134232a1974 (diff) | |
parent | 6473d4b65a99aa10d509220fb99d8c4f65631ed0 (diff) | |
download | unit-aff76e4f90b4e948c327ce2b021dc3203c33cbcd.tar.gz unit-aff76e4f90b4e948c327ce2b021dc3203c33cbcd.tar.bz2 |
Merged with the default branch.1.19.0-1
Diffstat (limited to 'src/nxt_socket.c')
-rw-r--r-- | src/nxt_socket.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/src/nxt_socket.c b/src/nxt_socket.c index cc3d7378..a8e0d514 100644 --- a/src/nxt_socket.c +++ b/src/nxt_socket.c @@ -51,18 +51,6 @@ nxt_socket_create(nxt_task_t *task, nxt_uint_t domain, nxt_uint_t type, void -nxt_socket_close(nxt_task_t *task, nxt_socket_t s) -{ - if (nxt_fast_path(close(s) == 0)) { - nxt_debug(task, "socket close(%d)", s); - - } else { - nxt_alert(task, "socket close(%d) failed %E", s, nxt_socket_errno); - } -} - - -void nxt_socket_defer_accept(nxt_task_t *task, nxt_socket_t s, nxt_sockaddr_t *sa) { #if (NXT_HAVE_UNIX_DOMAIN) @@ -291,6 +279,41 @@ nxt_socket_shutdown(nxt_task_t *task, nxt_socket_t s, nxt_uint_t how) } +void +nxt_socket_close(nxt_task_t *task, nxt_socket_t s) +{ + nxt_err_t err; + nxt_uint_t level; + + if (nxt_fast_path(close(s) == 0)) { + nxt_debug(task, "socket close(%d)", s); + return; + } + + err = nxt_socket_errno; + + switch (err) { + + case NXT_ENOTCONN: + level = NXT_LOG_DEBUG; + break; + + case NXT_ECONNRESET: + case NXT_ENETDOWN: + case NXT_ENETUNREACH: + case NXT_EHOSTDOWN: + case NXT_EHOSTUNREACH: + level = NXT_LOG_ERR; + break; + + default: + level = NXT_LOG_ALERT; + } + + nxt_log(task, level, "socket close(%d) failed %E", s, err); +} + + nxt_err_t nxt_socket_error(nxt_socket_t s) { |