mosh-server: Fix hang with ^S on OS X and FreeBSD.

Fixes #692.
This commit is contained in:
john hood
2015-11-23 01:41:07 -05:00
committed by John Hood
parent 551b77f27e
commit 8609f88207
3 changed files with 101 additions and 12 deletions
+7 -12
View File
@@ -638,6 +638,7 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
now = Network::timestamp();
uint64_t time_since_remote_state = now - network.get_latest_remote_state().timestamp;
string terminal_to_host;
if ( sel.read( network_fd ) ) {
/* packet received from the network */
@@ -647,7 +648,6 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
if ( network.get_remote_state_num() != last_remote_num ) {
last_remote_num = network.get_remote_state_num();
string terminal_to_host;
Network::UserStream us;
us.apply_string( network.get_remote_diff() );
@@ -687,11 +687,6 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
network.set_current_state( terminal );
}
/* write any writeback octets back to the host */
if ( swrite( host_fd, terminal_to_host.c_str(), terminal_to_host.length() ) < 0 ) {
break;
}
#ifdef HAVE_UTEMPTER
/* update utmp entry if we have become "connected" */
if ( (!connected_utmp)
@@ -734,18 +729,18 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &
if ( bytes_read <= 0 ) {
network.start_shutdown();
} else {
string terminal_to_host = terminal.act( string( buf, bytes_read ) );
terminal_to_host += terminal.act( string( buf, bytes_read ) );
/* update client with new state of terminal */
network.set_current_state( terminal );
/* write any writeback octets back to the host */
if ( swrite( host_fd, terminal_to_host.c_str(), terminal_to_host.length() ) < 0 ) {
break;
}
}
}
/* write user input and terminal writeback to the host */
if ( swrite( host_fd, terminal_to_host.c_str(), terminal_to_host.length() ) < 0 ) {
break;
}
bool idle_shutdown = false;
if ( network_timeout_ms &&
network_timeout_ms <= time_since_remote_state ) {