summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_socket.c
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-11-14 19:29:00 +0300
committerAndrei Belov <defan@nginx.com>2019-11-14 19:29:00 +0300
commit7630539c44fcb188bba03a65af34e952a81f2f38 (patch)
tree2c80f0cd315cae8079a39ba98ed89e02b5e1931a /src/nxt_socket.c
parent70c9f18b6e8b25850bce8eb1edba4d100c3e55d2 (diff)
parent0a27f137de776925a24406cf6961c550824c63a0 (diff)
downloadunit-7630539c44fcb188bba03a65af34e952a81f2f38.tar.gz
unit-7630539c44fcb188bba03a65af34e952a81f2f38.tar.bz2
Merged with the default branch.1.13.0-1
Diffstat (limited to 'src/nxt_socket.c')
-rw-r--r--src/nxt_socket.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/nxt_socket.c b/src/nxt_socket.c
index 95a298d8..2a809184 100644
--- a/src/nxt_socket.c
+++ b/src/nxt_socket.c
@@ -300,6 +300,28 @@ nxt_socket_shutdown(nxt_task_t *task, nxt_socket_t s, nxt_uint_t how)
}
+nxt_err_t
+nxt_socket_error(nxt_socket_t s)
+{
+ int ret, err;
+ socklen_t len;
+
+ err = 0;
+ len = sizeof(int);
+ /*
+ * Linux and BSDs return 0 and store a pending error in the err argument;
+ * Solaris returns -1 and sets the errno.
+ */
+ ret = getsockopt(s, SOL_SOCKET, SO_ERROR, (void *) &err, &len);
+
+ if (nxt_slow_path(ret == -1)) {
+ err = nxt_errno;
+ }
+
+ return err;
+}
+
+
nxt_uint_t
nxt_socket_error_level(nxt_err_t err)
{
@@ -315,6 +337,9 @@ nxt_socket_error_level(nxt_err_t err)
case NXT_EHOSTUNREACH:
return NXT_LOG_INFO;
+ case NXT_ECONNREFUSED:
+ return NXT_LOG_ERR;
+
default:
return NXT_LOG_ALERT;
}