client session BUGFIX handle socket timeout
Keep the socket for later connection attempt.
Fixes #244
diff --git a/src/session_client.c b/src/session_client.c
index 6a07473..d349c75 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -1380,9 +1380,14 @@
for (res = res_list; res != NULL; res = res->ai_next) {
sock = _non_blocking_connect(timeout, sock_pending, res, ka);
- if (sock == -1 && (!sock_pending || *sock_pending == -1)) {
- /* try the next resource */
- continue;
+ if (sock == -1) {
+ if (!sock_pending || *sock_pending == -1) {
+ /* try the next resource */
+ continue;
+ } else {
+ /* timeout, keep pending socket */
+ return -1;
+ }
}
VRB("Successfully connected to %s:%s over %s.", host, port_s, (res->ai_family == AF_INET6) ? "IPv6" : "IPv4");