diff --git a/src/nc_proxy.c b/src/nc_proxy.c index 38cdd9e6..132deb96 100644 --- a/src/nc_proxy.c +++ b/src/nc_proxy.c @@ -128,7 +128,7 @@ proxy_listen(struct context *ctx, struct conn *p) ASSERT(p->proxy); - p->sd = socket(p->family, SOCK_STREAM, 0); + p->sd = socket(p->family, SOCK_STREAM | SOCK_NONBLOCK, 0); if (p->sd < 0) { log_error("socket failed: %s", strerror(errno)); return NC_ERROR; @@ -166,13 +166,6 @@ proxy_listen(struct context *ctx, struct conn *p) return NC_ERROR; } - status = nc_set_nonblocking(p->sd); - if (status < 0) { - log_error("set nonblock on p %d on addr '%.*s' failed: %s", p->sd, - pool->addrstr.len, pool->addrstr.data, strerror(errno)); - return NC_ERROR; - } - status = event_add_conn(ctx->evb, p); if (status < 0) { log_error("event add conn p %d on addr '%.*s' failed: %s", diff --git a/src/nc_server.c b/src/nc_server.c index dab6a79b..c2a15c7d 100644 --- a/src/nc_server.c +++ b/src/nc_server.c @@ -483,7 +483,7 @@ server_connect(struct context *ctx, struct server *server, struct conn *conn) log_debug(LOG_VVERB, "connect to server '%.*s'", server->pname.len, server->pname.data); - conn->sd = socket(conn->family, SOCK_STREAM, 0); + conn->sd = socket(conn->family, SOCK_STREAM | SOCK_NONBLOCK, 0); if (conn->sd < 0) { log_error("socket for server '%.*s' failed: %s", server->pname.len, server->pname.data, strerror(errno)); @@ -491,14 +491,6 @@ server_connect(struct context *ctx, struct server *server, struct conn *conn) goto error; } - status = nc_set_nonblocking(conn->sd); - if (status != NC_OK) { - log_error("set nonblock on s %d for server '%.*s' failed: %s", - conn->sd, server->pname.len, server->pname.data, - strerror(errno)); - goto error; - } - if (server->pname.data[0] != '/') { status = nc_set_tcpnodelay(conn->sd); if (status != NC_OK) {