diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2015-08-16 19:24:15 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2015-08-16 19:24:15 +0200 |
commit | 15c5ebf0eb1300da7d85b715fc3a43892e49197b (patch) | |
tree | 1f575a352ce0c131a4e985496bc6141bc04aebfb | |
parent | c2408c9d74a780d3f1c502b78f4c47b15959a1a9 (diff) | |
download | cssh-15c5ebf0eb1300da7d85b715fc3a43892e49197b.tar.gz cssh-15c5ebf0eb1300da7d85b715fc3a43892e49197b.tar.bz2 |
avoid double non-blocking connects
-rw-r--r-- | src/cssh.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -390,20 +390,22 @@ int main( int argc, char *argv[] ) memset( is_connected, false, ( nof_sessions + 1 ) * sizeof( bool ) ); while( !all_connected ) { for( unsigned int i = 0; i < nof_sessions; i++ ) { - rc = ssh_connect( session[i] ); - if( rc == SSH_OK ) { - is_connected[i] = true; - //~ ssh_set_blocking( session[i], 1 ); - if( args_info.verbose_given ) { - fprintf( stderr, "Connected to '%s', port %d..\n", host[i], port[i] ); + if( !is_connected[i] ) { + rc = ssh_connect( session[i] ); + if( rc == SSH_OK ) { + is_connected[i] = true; + //~ ssh_set_blocking( session[i], 1 ); + if( args_info.verbose_given ) { + fprintf( stderr, "Connected to '%s', port %d..\n", host[i], port[i] ); + } + } else if( rc == SSH_AGAIN ) { + // not connected yet + } else { + fprintf( stderr, "ERROR: error connecting to '%s', port '%d': %s\n", + host[i], port[i], ssh_get_error( session[i] ) ); + cleanup_sessions( &session, NULL, host, port, nof_sessions, args_info.verbose_given > 0 ); + exit( EXIT_FAILURE ); } - } else if( rc == SSH_AGAIN ) { - // not connected yet - } else { - fprintf( stderr, "ERROR: error connecting to '%s', port '%d': %s\n", - host[i], port[i], ssh_get_error( session[i] ) ); - cleanup_sessions( &session, NULL, host, port, nof_sessions, args_info.verbose_given > 0 ); - exit( EXIT_FAILURE ); } } |