summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nxt_conn_connect.c2
-rw-r--r--src/nxt_controller.c2
-rw-r--r--src/nxt_listen_socket.c17
-rw-r--r--src/nxt_listen_socket.h2
-rw-r--r--src/nxt_runtime.c2
-rw-r--r--src/nxt_socket.c13
-rw-r--r--src/nxt_socket.h2
7 files changed, 9 insertions, 31 deletions
diff --git a/src/nxt_conn_connect.c b/src/nxt_conn_connect.c
index d045853f..220fb5f9 100644
--- a/src/nxt_conn_connect.c
+++ b/src/nxt_conn_connect.c
@@ -108,7 +108,7 @@ nxt_conn_socket(nxt_task_t *task, nxt_conn_t *c)
c->write_timer.task = task;
if (c->local != NULL) {
- if (nxt_slow_path(nxt_socket_bind(task, s, c->local, 0) != NXT_OK)) {
+ if (nxt_slow_path(nxt_socket_bind(task, s, c->local) != NXT_OK)) {
nxt_socket_close(task, s);
return NXT_ERROR;
}
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index ad292421..26f1d53a 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -431,7 +431,7 @@ nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt)
#endif
ls->handler = nxt_controller_conn_init;
- if (nxt_listen_socket_create(task, ls, 0) != NXT_OK) {
+ if (nxt_listen_socket_create(task, ls) != NXT_OK) {
return NXT_ERROR;
}
diff --git a/src/nxt_listen_socket.c b/src/nxt_listen_socket.c
index 9eeca690..63ab3de3 100644
--- a/src/nxt_listen_socket.c
+++ b/src/nxt_listen_socket.c
@@ -27,8 +27,7 @@ nxt_listen_socket(nxt_task_t *task, nxt_socket_t s, int backlog)
nxt_int_t
-nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls,
- nxt_bool_t bind_test)
+nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls)
{
nxt_log_t log, *old;
nxt_uint_t family;
@@ -81,16 +80,8 @@ nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls,
nxt_socket_defer_accept(task, s, sa);
}
- switch (nxt_socket_bind(task, s, sa, bind_test)) {
-
- case NXT_OK:
- break;
-
- case NXT_ERROR:
+ if (nxt_socket_bind(task, s, sa) != NXT_OK) {
goto fail;
-
- default: /* NXT_DECLINED: EADDRINUSE on bind() test */
- return NXT_OK;
}
#if (NXT_HAVE_UNIX_DOMAIN)
@@ -106,10 +97,6 @@ nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls,
if (nxt_file_set_access(name, access) != NXT_OK) {
goto fail;
}
-
- if (bind_test && nxt_file_delete(name) != NXT_OK) {
- goto fail;
- }
}
#endif
diff --git a/src/nxt_listen_socket.h b/src/nxt_listen_socket.h
index 80b95425..fac640de 100644
--- a/src/nxt_listen_socket.h
+++ b/src/nxt_listen_socket.h
@@ -55,7 +55,7 @@ NXT_EXPORT nxt_int_t nxt_listen_socket(nxt_task_t *task, nxt_socket_t s,
int backlog);
NXT_EXPORT nxt_int_t nxt_listen_socket_create(nxt_task_t *task,
- nxt_listen_socket_t *ls, nxt_bool_t bind_test);
+ nxt_listen_socket_t *ls);
NXT_EXPORT nxt_int_t nxt_listen_socket_update(nxt_task_t *task,
nxt_listen_socket_t *ls, nxt_listen_socket_t *prev);
NXT_EXPORT void nxt_listen_socket_remote_size(nxt_listen_socket_t *ls);
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index f6d80ccb..09fad1de 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -1205,7 +1205,7 @@ nxt_runtime_listen_sockets_create(nxt_task_t *task, nxt_runtime_t *rt)
}
}
- if (nxt_listen_socket_create(task, &curr[c], 0) != NXT_OK) {
+ if (nxt_listen_socket_create(task, &curr[c]) != NXT_OK) {
return NXT_ERROR;
}
diff --git a/src/nxt_socket.c b/src/nxt_socket.c
index 2a809184..cc3d7378 100644
--- a/src/nxt_socket.c
+++ b/src/nxt_socket.c
@@ -184,11 +184,8 @@ nxt_socket_sockopt_name(nxt_uint_t level, nxt_uint_t sockopt)
nxt_int_t
-nxt_socket_bind(nxt_task_t *task, nxt_socket_t s, nxt_sockaddr_t *sa,
- nxt_bool_t test)
+nxt_socket_bind(nxt_task_t *task, nxt_socket_t s, nxt_sockaddr_t *sa)
{
- nxt_err_t err;
-
nxt_debug(task, "bind(%d, %*s)", s, (size_t) sa->length,
nxt_sockaddr_start(sa));
@@ -196,14 +193,8 @@ nxt_socket_bind(nxt_task_t *task, nxt_socket_t s, nxt_sockaddr_t *sa,
return NXT_OK;
}
- err = nxt_socket_errno;
-
- if (err == NXT_EADDRINUSE && test) {
- return NXT_DECLINED;
- }
-
nxt_alert(task, "bind(%d, %*s) failed %E",
- s, (size_t) sa->length, nxt_sockaddr_start(sa), err);
+ s, (size_t) sa->length, nxt_sockaddr_start(sa), nxt_socket_errno);
return NXT_ERROR;
}
diff --git a/src/nxt_socket.h b/src/nxt_socket.h
index 6a450f83..e39d8e4d 100644
--- a/src/nxt_socket.h
+++ b/src/nxt_socket.h
@@ -101,7 +101,7 @@ NXT_EXPORT nxt_int_t nxt_socket_getsockopt(nxt_task_t *task, nxt_socket_t s,
NXT_EXPORT nxt_int_t nxt_socket_setsockopt(nxt_task_t *task, nxt_socket_t s,
nxt_uint_t level, nxt_uint_t sockopt, int val);
NXT_EXPORT nxt_int_t nxt_socket_bind(nxt_task_t *task, nxt_socket_t s,
- nxt_sockaddr_t *sa, nxt_bool_t test);
+ nxt_sockaddr_t *sa);
NXT_EXPORT nxt_int_t nxt_socket_connect(nxt_task_t *task, nxt_socket_t s,
nxt_sockaddr_t *sa);
NXT_EXPORT void nxt_socket_shutdown(nxt_task_t *task, nxt_socket_t s,