mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-17 11:43:37 +00:00
Only use signal() in ssl_server2 on non-Windows platforms
This commit is contained in:
parent
dcab293bd4
commit
c1283d3f4c
@ -63,7 +63,10 @@ int main( int argc, char *argv[] )
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "polarssl/net.h"
|
#include "polarssl/net.h"
|
||||||
#include "polarssl/ssl.h"
|
#include "polarssl/ssl.h"
|
||||||
@ -565,6 +568,7 @@ int psk_callback( void *p_info, ssl_context *ssl,
|
|||||||
}
|
}
|
||||||
#endif /* POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED */
|
#endif /* POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED */
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
/* Interruption handler to ensure clean exit (for valgrind testing) */
|
/* Interruption handler to ensure clean exit (for valgrind testing) */
|
||||||
static int listen_fd;
|
static int listen_fd;
|
||||||
static int received_sigterm = 0;
|
static int received_sigterm = 0;
|
||||||
@ -574,6 +578,7 @@ void term_handler( int sig )
|
|||||||
received_sigterm = 1;
|
received_sigterm = 1;
|
||||||
net_close( listen_fd ); /* causes net_accept() to abort */
|
net_close( listen_fd ); /* causes net_accept() to abort */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
@ -645,8 +650,10 @@ int main( int argc, char *argv[] )
|
|||||||
memset( (void *) alpn_list, 0, sizeof( alpn_list ) );
|
memset( (void *) alpn_list, 0, sizeof( alpn_list ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(_WIN32)
|
||||||
/* Abort cleanly on SIGTERM */
|
/* Abort cleanly on SIGTERM */
|
||||||
signal( SIGTERM, term_handler );
|
signal( SIGTERM, term_handler );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( argc == 0 )
|
if( argc == 0 )
|
||||||
{
|
{
|
||||||
@ -1390,12 +1397,14 @@ reset:
|
|||||||
|
|
||||||
if( ( ret = net_accept( listen_fd, &client_fd, NULL ) ) != 0 )
|
if( ( ret = net_accept( listen_fd, &client_fd, NULL ) ) != 0 )
|
||||||
{
|
{
|
||||||
|
#if !defined(_WIN32)
|
||||||
if( received_sigterm )
|
if( received_sigterm )
|
||||||
{
|
{
|
||||||
printf( " interrupted by SIGTERM\n" );
|
printf( " interrupted by SIGTERM\n" );
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
printf( " failed\n ! net_accept returned -0x%x\n\n", -ret );
|
printf( " failed\n ! net_accept returned -0x%x\n\n", -ret );
|
||||||
goto exit;
|
goto exit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user