[PATCH] lib/tsocket: fix non-blockging connect() error handling
Ralph Boehme
rb at sernet.de
Wed Oct 21 14:28:01 UTC 2015
Hi!
Attached is a small fix for tsocket.
It's already rb: metze, so I'll push later on if nobody objects.
-slow
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
-------------- next part --------------
From 2eeaa45ba10edb164c8969388cc4a336a24ef4bd Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Wed, 21 Oct 2015 16:08:00 +0200
Subject: [PATCH] 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 at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
lib/tsocket/tsocket_bsd.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 8203755..ac0617d 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;
}
--
2.1.0
More information about the samba-technical
mailing list