Skip to content

Commit

Permalink
Display sendto() exception until a successful send
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcallister authored and keithw committed May 9, 2012
1 parent c258e0b commit 02c04fb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/frontend/stmclient.cc
Expand Up @@ -419,6 +419,8 @@ void STMClient::main( void )
const Network::NetworkException *exn = network->get_send_exception();
if ( exn ) {
overlays.get_notification_engine().set_network_exception( *exn );
} else {
overlays.get_notification_engine().clear_network_exception();
}
} catch ( Network::NetworkException e ) {
if ( !network->shutdown_in_progress() ) {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/terminaloverlay.cc
Expand Up @@ -153,6 +153,7 @@ NotificationEngine::NotificationEngine()
: last_word_from_server( timestamp() ),
last_acked_state( timestamp() ),
message(),
message_is_network_exception( false ),
message_expiration( -1 )
{}

Expand Down
15 changes: 14 additions & 1 deletion src/frontend/terminaloverlay.h
Expand Up @@ -21,6 +21,7 @@

#include "terminalframebuffer.h"
#include "network.h"
#include "transportsender.h"
#include "parser.h"

#include <vector>
Expand Down Expand Up @@ -129,6 +130,7 @@ namespace Overlay {
uint64_t last_word_from_server;
uint64_t last_acked_state;
wstring message;
bool message_is_network_exception;
uint64_t message_expiration;

public:
Expand All @@ -150,13 +152,24 @@ namespace Overlay {
} else {
message_expiration = timestamp() + 1000;
}
message_is_network_exception = false;
}

void set_network_exception( const NetworkException &e )
{
wchar_t tmp[ 128 ];
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();
Expand Down

0 comments on commit 02c04fb

Please sign in to comment.