# HG changeset patch # User Matt Johnston # Date 1423878971 -28800 # Node ID 4121ca987e6a137e1f83a3100a68632f5f353fe6 # Parent 24135c8e1d46c5dd74665899a28d8b67930334ed connect_remote() is now always non-blocking diff -r 24135c8e1d46 -r 4121ca987e6a cli-main.c --- a/cli-main.c Fri Feb 13 23:47:53 2015 +0800 +++ b/cli-main.c Sat Feb 14 09:56:11 2015 +0800 @@ -72,8 +72,7 @@ } else #endif { - int sock = connect_remote(cli_opts.remotehost, cli_opts.remoteport, - 1, &error); + int sock = connect_remote(cli_opts.remotehost, cli_opts.remoteport, &error); sock_in = sock_out = sock; } diff -r 24135c8e1d46 -r 4121ca987e6a cli-tcpfwd.c --- a/cli-tcpfwd.c Fri Feb 13 23:47:53 2015 +0800 +++ b/cli-tcpfwd.c Sat Feb 14 09:56:11 2015 +0800 @@ -254,7 +254,7 @@ } snprintf(portstring, sizeof(portstring), "%d", fwd->connectport); - sock = connect_remote(fwd->connectaddr, portstring, 1, NULL); + sock = connect_remote(fwd->connectaddr, portstring, NULL); if (sock < 0) { TRACE(("leave newtcpdirect: sock failed")) err = SSH_OPEN_CONNECT_FAILED; diff -r 24135c8e1d46 -r 4121ca987e6a dbutil.c --- a/dbutil.c Fri Feb 13 23:47:53 2015 +0800 +++ b/dbutil.c Sat Feb 14 09:56:11 2015 +0800 @@ -435,8 +435,7 @@ * wasn't null, it will be a newly malloced error message */ /* TODO: maxfd */ -int connect_remote(const char* remotehost, const char* remoteport, - int nonblocking, char ** errstring) { +int connect_remote(const char* remotehost, const char* remoteport, char ** errstring) { struct addrinfo *res0 = NULL, *res = NULL, hints; int sock; @@ -475,16 +474,14 @@ continue; } - if (nonblocking) { - setnonblocking(sock); + setnonblocking(sock); #if defined(__linux__) && defined(TCP_DEFER_ACCEPT) - set_piggyback_ack(sock); + set_piggyback_ack(sock); #endif - } if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) { - if (errno == EINPROGRESS && nonblocking) { + if (errno == EINPROGRESS) { TRACE(("Connect in progress")) break; } else { @@ -498,7 +495,7 @@ break; /* Success */ } - if (sock < 0 && !(errno == EINPROGRESS && nonblocking)) { + if (sock < 0 && !(errno == EINPROGRESS)) { /* Failed */ if (errstring != NULL && *errstring == NULL) { int len; diff -r 24135c8e1d46 -r 4121ca987e6a dbutil.h --- a/dbutil.h Fri Feb 13 23:47:53 2015 +0800 +++ b/dbutil.h Sat Feb 14 09:56:11 2015 +0800 @@ -83,8 +83,7 @@ #ifdef ENABLE_CONNECT_UNIX int connect_unix(const char* addr); #endif -int connect_remote(const char* remotehost, const char* remoteport, - int nonblocking, char ** errstring); +int connect_remote(const char* remotehost, const char* remoteport, char ** errstring); int buf_readfile(buffer* buf, const char* filename); int buf_getline(buffer * line, FILE * authfile); diff -r 24135c8e1d46 -r 4121ca987e6a svr-tcpfwd.c --- a/svr-tcpfwd.c Fri Feb 13 23:47:53 2015 +0800 +++ b/svr-tcpfwd.c Sat Feb 14 09:56:11 2015 +0800 @@ -270,7 +270,7 @@ } snprintf(portstring, sizeof(portstring), "%d", destport); - sock = connect_remote(desthost, portstring, 1, NULL); + sock = connect_remote(desthost, portstring, NULL); if (sock < 0) { err = SSH_OPEN_CONNECT_FAILED; TRACE(("leave newtcpdirect: sock failed"))