From c1283d3f4c8dc46a19cb89a530a0854e2dd701eb Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Mon, 18 Aug 2014 11:05:51 +0200
Subject: [PATCH] Only use signal() in ssl_server2 on non-Windows platforms
---
programs/ssl/ssl_server2.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index 125466a10..717f788e1 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -63,7 +63,10 @@ int main( int argc, char *argv[] )
#include
#include
#include
+
+#if !defined(_WIN32)
#include
+#endif
#include "polarssl/net.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 */
+#if !defined(_WIN32)
/* Interruption handler to ensure clean exit (for valgrind testing) */
static int listen_fd;
static int received_sigterm = 0;
@@ -574,6 +578,7 @@ void term_handler( int sig )
received_sigterm = 1;
net_close( listen_fd ); /* causes net_accept() to abort */
}
+#endif
int main( int argc, char *argv[] )
{
@@ -645,8 +650,10 @@ int main( int argc, char *argv[] )
memset( (void *) alpn_list, 0, sizeof( alpn_list ) );
#endif
+#if !defined(_WIN32)
/* Abort cleanly on SIGTERM */
signal( SIGTERM, term_handler );
+#endif
if( argc == 0 )
{
@@ -1390,12 +1397,14 @@ reset:
if( ( ret = net_accept( listen_fd, &client_fd, NULL ) ) != 0 )
{
+#if !defined(_WIN32)
if( received_sigterm )
{
printf( " interrupted by SIGTERM\n" );
ret = 0;
goto exit;
}
+#endif
printf( " failed\n ! net_accept returned -0x%x\n\n", -ret );
goto exit;