diff options
-rw-r--r-- | src/coordinator.c | 11 | ||||
-rw-r--r-- | src/master.c | 9 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/coordinator.c b/src/coordinator.c index 4403999..77ff484 100644 --- a/src/coordinator.c +++ b/src/coordinator.c @@ -65,6 +65,14 @@ static void *coordinator_func( void *thread_data ) int msg_size = strlen( msg ) + 1; printf( "coordinator send: %s\n", msg ); bytes = nn_send( coordinator_sock, msg, msg_size, 0 ); + if( bytes < 0 ) { + if( errno == ETERM ) { + goto END; + } else { + fprintf( stderr, "ERROR: nn_send returned %d: %s (%d)\n", + bytes, nn_strerror( errno ), errno ); + } + } if( bytes != msg_size ) { fprintf( stderr, "ERROR: truncated message!" ); } @@ -79,7 +87,8 @@ static void *coordinator_func( void *thread_data ) } } } - + + END: (void)nn_shutdown( coordinator_sock, 0 ); puts( "coordinator disconnected" ); diff --git a/src/master.c b/src/master.c index d2c3728..a73a7b1 100644 --- a/src/master.c +++ b/src/master.c @@ -39,6 +39,14 @@ NEXT_DISCOVER: int msg_size = strlen( msg ) + 1; printf( "master send: %s\n", msg ); int bytes = nn_send( master_sock, msg, msg_size, 0 ); + if( bytes < 0 ) { + if( errno == ETERM ) { + goto END; + } else { + fprintf( stderr, "ERROR: nn_send returned %d: %s (%d)\n", + bytes, nn_strerror( errno ), errno ); + } + } if( bytes != msg_size ) { fprintf( stderr, "ERROR: truncated message!" ); } @@ -70,6 +78,7 @@ NEXT_DISCOVER: } } } +END: (void)nn_shutdown( master_sock, 0 ); |