Display sendto() exception until a successful send

This commit is contained in:
Keegan McAllister
2012-05-02 18:38:18 -04:00
committed by Keith Winstein
parent c258e0bc4e
commit 02c04fbdaa
3 changed files with 17 additions and 1 deletions
+2
View File
@@ -419,6 +419,8 @@ void STMClient::main( void )
const Network::NetworkException *exn = network->get_send_exception(); const Network::NetworkException *exn = network->get_send_exception();
if ( exn ) { if ( exn ) {
overlays.get_notification_engine().set_network_exception( *exn ); overlays.get_notification_engine().set_network_exception( *exn );
} else {
overlays.get_notification_engine().clear_network_exception();
} }
} catch ( Network::NetworkException e ) { } catch ( Network::NetworkException e ) {
if ( !network->shutdown_in_progress() ) { if ( !network->shutdown_in_progress() ) {
+1
View File
@@ -153,6 +153,7 @@ NotificationEngine::NotificationEngine()
: last_word_from_server( timestamp() ), : last_word_from_server( timestamp() ),
last_acked_state( timestamp() ), last_acked_state( timestamp() ),
message(), message(),
message_is_network_exception( false ),
message_expiration( -1 ) message_expiration( -1 )
{} {}
+14 -1
View File
@@ -21,6 +21,7 @@
#include "terminalframebuffer.h" #include "terminalframebuffer.h"
#include "network.h" #include "network.h"
#include "transportsender.h"
#include "parser.h" #include "parser.h"
#include <vector> #include <vector>
@@ -129,6 +130,7 @@ namespace Overlay {
uint64_t last_word_from_server; uint64_t last_word_from_server;
uint64_t last_acked_state; uint64_t last_acked_state;
wstring message; wstring message;
bool message_is_network_exception;
uint64_t message_expiration; uint64_t message_expiration;
public: public:
@@ -150,13 +152,24 @@ namespace Overlay {
} else { } else {
message_expiration = timestamp() + 1000; message_expiration = timestamp() + 1000;
} }
message_is_network_exception = false;
} }
void set_network_exception( const NetworkException &e ) void set_network_exception( const NetworkException &e )
{ {
wchar_t tmp[ 128 ]; wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"%s: %s", e.function.c_str(), strerror( e.the_errno ) ); swprintf( tmp, 128, L"%s: %s", e.function.c_str(), strerror( e.the_errno ) );
set_notification_string( wstring( tmp ) );
message = tmp;
message_is_network_exception = true;
message_expiration = timestamp() + Network::ACK_INTERVAL + 100;
}
void clear_network_exception()
{
if ( message_is_network_exception ) {
set_notification_string( wstring( L"" ) );
}
} }
NotificationEngine(); NotificationEngine();