aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2011-08-05 10:30:54 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-07 12:47:23 +0200
commit1204f43ea92dbc57a06a45b9293255104d940705 (patch)
treeb4d77d7706d81ec4f58d9dcb5c2db5781bf799da
parentb542bc9e4e0cda2d86f6ddf95b31e6b9fbc20a96 (diff)
downloadlibssh-1204f43ea92dbc57a06a45b9293255104d940705.tar.gz
libssh-1204f43ea92dbc57a06a45b9293255104d940705.tar.xz
libssh-1204f43ea92dbc57a06a45b9293255104d940705.zip
client: Fix another source of endless wait.
(cherry picked from commit 35686b4822c8a18d1d6715221be91ee67e563bad)
-rw-r--r--src/auth.c2
-rw-r--r--src/client.c26
2 files changed, 15 insertions, 13 deletions
diff --git a/src/auth.c b/src/auth.c
index af699918..6dda4792 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -254,7 +254,7 @@ static int wait_auth_status(ssh_session session) {
enter_function();
if(ssh_is_blocking(session)){
- if(ssh_handle_packets_termination(session,-1,auth_status_termination,
+ if(ssh_handle_packets_termination(session, -2, auth_status_termination,
session) == SSH_ERROR){
leave_function();
return SSH_AUTH_ERROR;
diff --git a/src/client.c b/src/client.c
index 84a0ad92..df8f08e4 100644
--- a/src/client.c
+++ b/src/client.c
@@ -684,19 +684,21 @@ int ssh_connect(ssh_session session) {
session->alive = 1;
ssh_log(session,SSH_LOG_PROTOCOL,"Socket connecting, now waiting for the callbacks to work");
pending:
- session->pending_call_state=SSH_PENDING_CALL_CONNECT;
- if(ssh_is_blocking(session)) {
- int timeout = session->timeout * 1000 + session->timeout_usec;
- if (timeout <= 0)
- timeout = -1;
- ssh_handle_packets_termination(session,timeout,ssh_connect_termination,session);
- if(!ssh_connect_termination(session)){
- ssh_set_error(session,SSH_FATAL,"Timeout connecting to %s",session->host);
- session->session_state = SSH_SESSION_STATE_ERROR;
- }
- }
+ session->pending_call_state=SSH_PENDING_CALL_CONNECT;
+ if(ssh_is_blocking(session)) {
+ int timeout = (session->timeout * 1000) + (session->timeout_usec / 1000);
+ if (timeout == 0) {
+ timeout = 10 * 1000;
+ }
+ ssh_log(session,SSH_LOG_PACKET,"ssh_connect: Actual timeout : %d", timeout);
+ ssh_handle_packets_termination(session, timeout, ssh_connect_termination, session);
+ if(!ssh_connect_termination(session)){
+ ssh_set_error(session,SSH_FATAL,"Timeout connecting to %s",session->host);
+ session->session_state = SSH_SESSION_STATE_ERROR;
+ }
+ }
else
- ssh_handle_packets_termination(session,0,ssh_connect_termination, session);
+ ssh_handle_packets_termination(session, 0, ssh_connect_termination, session);
ssh_log(session,SSH_LOG_PACKET,"ssh_connect: Actual state : %d",session->session_state);
if(!ssh_is_blocking(session) && !ssh_connect_termination(session)){
leave_function();