Merge miscellaneous fixes into development

This commit is contained in:
Paul Bakker 2015-01-13 16:04:38 +01:00
commit d7e2483bfc
57 changed files with 1292 additions and 369 deletions

View file

@ -592,7 +592,7 @@ int psk_callback( void *p_info, ssl_context *ssl,
}
#endif /* POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED */
static int listen_fd;
static int listen_fd, client_fd = -1;
/* Interruption handler to ensure clean exit (for valgrind testing) */
#if !defined(_WIN32)
@ -602,13 +602,13 @@ void term_handler( int sig )
((void) sig);
received_sigterm = 1;
net_close( listen_fd ); /* causes net_accept() to abort */
net_close( client_fd ); /* causes net_read() to abort */
}
#endif
int main( int argc, char *argv[] )
{
int ret = 0, len, written, frags, exchanges;
int client_fd = -1;
int version_suites[4][2];
unsigned char buf[IO_BUF_LEN];
#if defined(POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED)
@ -676,8 +676,9 @@ int main( int argc, char *argv[] )
#endif
#if !defined(_WIN32)
/* Abort cleanly on SIGTERM */
/* Abort cleanly on SIGTERM and SIGINT */
signal( SIGTERM, term_handler );
signal( SIGINT, term_handler );
#endif
if( argc == 0 )
@ -1435,6 +1436,15 @@ int main( int argc, char *argv[] )
printf( " ok\n" );
reset:
#if !defined(_WIN32)
if( received_sigterm )
{
printf( " interrupted by SIGTERM\n" );
ret = 0;
goto exit;
}
#endif
#ifdef POLARSSL_ERROR_C
if( ret != 0 )
{
@ -1462,7 +1472,7 @@ reset:
#if !defined(_WIN32)
if( received_sigterm )
{
printf( " interrupted by SIGTERM\n" );
printf( " interrupted by signal\n" );
ret = 0;
goto exit;
}
@ -1750,6 +1760,9 @@ exit:
}
#endif
printf( " . Cleaning up..." );
fflush( stdout );
if( client_fd != -1 )
net_close( client_fd );
@ -1788,6 +1801,8 @@ exit:
memory_buffer_alloc_free();
#endif
printf( " done.\n" );
#if defined(_WIN32)
printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();