From 3e705adcab8404ee6e5f71a38e98eeaca29a5b61 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 21 Oct 2015 16:08:00 +0200 Subject: lib/tsocket: fix non-blockging connect() error handling Non-blockging connect() either returns immediate success, or -1 with errno EINPROGESS as indication that the connection is pending. All other errnos indicate immediate failure. Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- lib/tsocket/tsocket_bsd.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/tsocket') diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c index 8203755e5d1..ac0617d6578 100644 --- a/lib/tsocket/tsocket_bsd.c +++ b/lib/tsocket/tsocket_bsd.c @@ -2114,8 +2114,6 @@ static struct tevent_req *tstream_bsd_connect_send(TALLOC_CTX *mem_ctx, talloc_get_type_abort(remote->private_data, struct tsocket_address_bsd); int ret; - int err; - bool retry; bool do_bind = false; bool do_reuseaddr = false; bool do_ipv6only = false; @@ -2256,12 +2254,11 @@ static struct tevent_req *tstream_bsd_connect_send(TALLOC_CTX *mem_ctx, } ret = connect(state->fd, &rbsda->u.sa, rbsda->sa_socklen); - err = tsocket_bsd_error_from_errno(ret, errno, &retry); - if (retry) { - /* retry later */ - goto async; - } - if (tevent_req_error(req, err)) { + if (ret == -1) { + if (errno == EINPROGRESS) { + goto async; + } + tevent_req_error(req, errno); goto post; } -- cgit v1.2.1