Put spin debug under -vv flag, and add to mosh-client

This commit is contained in:
John Hood
2016-10-29 01:41:21 -04:00
parent f89f1da0b5
commit 9ffbeddbc8
13 changed files with 47 additions and 23 deletions
+6 -2
View File
@@ -99,6 +99,7 @@ int mosh_main( int argc, char *argv[] )
int main( int argc, char *argv[] )
#endif
{
unsigned int verbose = 0;
/* For security, make sure we don't dump core */
Crypto::disable_dumping_core();
@@ -107,7 +108,7 @@ int main( int argc, char *argv[] )
/* Get arguments */
int opt;
while ( (opt = getopt( argc, argv, "#:c" )) != -1 ) {
while ( (opt = getopt( argc, argv, "#:cv" )) != -1 ) {
switch ( opt ) {
case '#':
// Ignore the original arguments to mosh wrapper
@@ -116,6 +117,9 @@ int main( int argc, char *argv[] )
print_colorcount();
exit( 0 );
break;
case 'v':
verbose++;
break;
default:
usage( argv[ 0 ] );
exit( 1 );
@@ -168,7 +172,7 @@ int main( int argc, char *argv[] )
bool success = false;
try {
STMClient client( ip, desired_port, key, predict_mode );
STMClient client( ip, desired_port, key, predict_mode, verbose );
client.init();
try {
+7 -8
View File
@@ -102,7 +102,7 @@ static void serve( int host_fd,
static int run_server( const char *desired_ip, const char *desired_port,
const string &command_path, char *command_argv[],
const int colors, bool verbose, bool with_motd );
const int colors, unsigned int verbose, bool with_motd );
using namespace std;
@@ -171,7 +171,7 @@ int main( int argc, char *argv[] )
string command_path;
char **command_argv = NULL;
int colors = 0;
bool verbose = false; /* don't close stdin/stdout/stderr */
unsigned int verbose = 0; /* don't close stdin/stdout/stderr */
/* Will cause mosh-server not to correctly detach on old versions of sshd. */
list<string> locale_vars;
@@ -231,7 +231,7 @@ int main( int argc, char *argv[] )
}
break;
case 'v':
verbose = true;
verbose++;
break;
case 'l':
locale_vars.push_back( string( optarg ) );
@@ -355,7 +355,7 @@ int main( int argc, char *argv[] )
static int run_server( const char *desired_ip, const char *desired_port,
const string &command_path, char *command_argv[],
const int colors, bool verbose, bool with_motd ) {
const int colors, unsigned int verbose, bool with_motd ) {
/* get network idle timeout */
long network_timeout = 0;
char *timeout_envar = getenv( "MOSH_SERVER_NETWORK_TMOUT" );
@@ -403,9 +403,8 @@ static int run_server( const char *desired_ip, const char *desired_port,
Network::UserStream blank;
ServerConnection *network = new ServerConnection( terminal, blank, desired_ip, desired_port );
if ( verbose ) {
network->set_verbose();
}
network->set_verbose( verbose );
Select::set_verbose( verbose );
/*
* If mosh-server is run on a pty, then typeahead may echo and break mosh.pl's
@@ -456,7 +455,7 @@ static int run_server( const char *desired_ip, const char *desired_port,
int master;
/* close file descriptors */
if ( !verbose ) {
if ( verbose == 0 ) {
/* Necessary to properly detach on old versions of sshd (e.g. RHEL/CentOS 5.0). */
int nullfd;
+4
View File
@@ -255,6 +255,10 @@ void STMClient::main_init( void )
/* tell server the size of the terminal */
network->get_current_state().push_back( Parser::Resize( window_size.ws_col, window_size.ws_row ) );
/* be noisy as necessary */
network->set_verbose( verbose );
Select::set_verbose( verbose );
}
void STMClient::output_new_frame( void )
+4 -2
View File
@@ -66,6 +66,7 @@ private:
std::wstring connecting_notification;
bool repaint_requested, lf_entered, quit_sequence_started;
bool clean_shutdown;
unsigned int verbose;
void main_init( void );
void process_network_input( void );
@@ -83,7 +84,7 @@ private:
void resume( void ); /* restore state after SIGCONT */
public:
STMClient( const char *s_ip, const char *s_port, const char *s_key, const char *predict_mode )
STMClient( const char *s_ip, const char *s_port, const char *s_key, const char *predict_mode, unsigned int s_verbose )
: ip( s_ip ? s_ip : "" ), port( s_port ? s_port : "" ),
key( s_key ? s_key : "" ),
escape_key( 0x1E ), escape_pass_key( '^' ), escape_pass_key2( '^' ),
@@ -99,7 +100,8 @@ public:
repaint_requested( false ),
lf_entered( false ),
quit_sequence_started( false ),
clean_shutdown( false )
clean_shutdown( false ),
verbose( s_verbose )
{
if ( predict_mode ) {
if ( !strcmp( predict_mode, "always" ) ) {
+2 -2
View File
@@ -49,7 +49,7 @@ Transport<MyState, RemoteState>::Transport( MyState &initial_state, RemoteState
receiver_quench_timer( 0 ),
last_receiver_state( initial_remote ),
fragments(),
verbose( false )
verbose( 0 )
{
/* server */
}
@@ -63,7 +63,7 @@ Transport<MyState, RemoteState>::Transport( MyState &initial_state, RemoteState
receiver_quench_timer( 0 ),
last_receiver_state( initial_remote ),
fragments(),
verbose( false )
verbose( 0 )
{
/* client */
}
+2 -2
View File
@@ -63,7 +63,7 @@ namespace Network {
uint64_t receiver_quench_timer;
RemoteState last_receiver_state; /* the state we were in when user last queried state */
FragmentAssembly fragments;
bool verbose;
unsigned int verbose;
public:
Transport( MyState &initial_state, RemoteState &initial_remote,
@@ -106,7 +106,7 @@ namespace Network {
const std::vector< int > fds( void ) const { return connection.fds(); }
void set_verbose( void ) { sender.set_verbose(); verbose = true; }
void set_verbose( unsigned int s_verbose ) { sender.set_verbose( s_verbose ); verbose = s_verbose; }
void set_send_delay( int new_delay ) { sender.set_send_delay( new_delay ); }
+1 -1
View File
@@ -56,7 +56,7 @@ TransportSender<MyState>::TransportSender( Connection *s_connection, MyState &in
fragmenter(),
next_ack_time( timestamp() ),
next_send_time( timestamp() ),
verbose( false ),
verbose( 0 ),
shutdown_in_progress( false ),
shutdown_tries( 0 ),
shutdown_start( -1 ),
+2 -2
View File
@@ -91,7 +91,7 @@ namespace Network {
void calculate_timers( void );
bool verbose;
unsigned int verbose;
bool shutdown_in_progress;
int shutdown_tries;
uint64_t shutdown_start;
@@ -144,7 +144,7 @@ namespace Network {
current_state = x;
current_state.reset_input();
}
void set_verbose( void ) { verbose = true; }
void set_verbose( unsigned int s_verbose ) { verbose = s_verbose; }
bool get_shutdown_in_progress( void ) const { return shutdown_in_progress; }
bool get_shutdown_acknowledged( void ) const { return sent_states.front().num == uint64_t(-1); }
+1 -1
View File
@@ -102,7 +102,7 @@ mosh_server()
test_error "mosh_server: variables missing\n"
fi
exec 2> "${MOSH_E2E_TEST}.server.stderr"
exec "$MOSH_SERVER" new -v $MOSH_SERVER_ARGS -@ "$@"
exec "$MOSH_SERVER" new -vv $MOSH_SERVER_ARGS -@ "$@"
}
# main
+2
View File
@@ -36,6 +36,8 @@ fd_set Select::dummy_fd_set;
sigset_t Select::dummy_sigset;
unsigned int Select::verbose = 0;
void Select::handle_signal( int signum )
{
fatal_assert( signum >= 0 );
+8 -2
View File
@@ -122,13 +122,16 @@ public:
clear_got_signal();
/* Rate-limit and warn about polls. */
if ( verbose > 1 && timeout == 0 ) {
fprintf( stderr, "%s: got poll (timeout 0)\n", __func__ );
}
if ( timeout == 0 && ++consecutive_polls >= MAX_POLLS ) {
if ( consecutive_polls == MAX_POLLS ) {
if ( verbose > 1 && consecutive_polls == MAX_POLLS ) {
fprintf( stderr, "%s: got %d polls, rate limiting.\n", __func__, MAX_POLLS );
}
timeout = 1;
} else if ( timeout != 0 && consecutive_polls ) {
if ( consecutive_polls >= MAX_POLLS ) {
if ( verbose > 1 && consecutive_polls >= MAX_POLLS ) {
fprintf( stderr, "%s: got %d consecutive polls\n", __func__, consecutive_polls );
}
consecutive_polls = 0;
@@ -212,6 +215,8 @@ public:
return rv;
}
static void set_verbose( unsigned int s_verbose ) { verbose = s_verbose; }
private:
static const int MAX_SIGNAL_NUMBER = 64;
/* Number of 0-timeout selects after which we begin to think
@@ -233,6 +238,7 @@ private:
static fd_set dummy_fd_set;
static sigset_t dummy_sigset;
int consecutive_polls;
static unsigned int verbose;
};
#endif