diff options
author | Ralph Boehme <slow@samba.org> | 2015-10-21 16:08:00 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2015-10-21 23:13:17 +0200 |
commit | 3e705adcab8404ee6e5f71a38e98eeaca29a5b61 (patch) | |
tree | 287e5121cacc53672097704d0722f0522a4394ff /lib/tsocket | |
parent | 41fe3cfcb5fa2441da9180e57255a3b7fa23da12 (diff) | |
download | samba-3e705adcab8404ee6e5f71a38e98eeaca29a5b61.tar.gz |
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 <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/tsocket')
-rw-r--r-- | lib/tsocket/tsocket_bsd.c | 13 |
1 files changed, 5 insertions, 8 deletions
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; } |