diff --git a/miniupnpc/minihttptestserver.c b/miniupnpc/minihttptestserver.c index b7a5cea..08575e7 100644 --- a/miniupnpc/minihttptestserver.c +++ b/miniupnpc/minihttptestserver.c @@ -1,7 +1,7 @@ -/* $Id: minihttptestserver.c,v 1.19 2015/11/17 09:07:17 nanard Exp $ */ +/* $Id: minihttptestserver.c,v 1.21 2017/11/02 16:52:37 nanard Exp $ */ /* Project : miniUPnP * Author : Thomas Bernard - * Copyright (c) 2011-2016 Thomas Bernard + * Copyright (c) 2011-2017 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * */ @@ -24,6 +24,8 @@ #define CRAP_LENGTH (2048) +static int server(unsigned short port, const char * expected_file_name, int ipv6); + volatile sig_atomic_t quit = 0; volatile sig_atomic_t child_to_wait_for = 0; @@ -485,17 +487,9 @@ void handle_http_connection(int c) */ int main(int argc, char * * argv) { int ipv6 = 0; - int s, c, i; + int r, i; unsigned short port = 0; - struct sockaddr_storage server_addr; - socklen_t server_addrlen; - struct sockaddr_storage client_addr; - socklen_t client_addrlen; - pid_t pid; - int child = 0; - int status; const char * expected_file_name = NULL; - struct sigaction sa; for(i = 1; i < argc; i++) { if(argv[i][0] == '-') { @@ -523,6 +517,26 @@ int main(int argc, char * * argv) { srand(time(NULL)); + r = server(port, expected_file_name, ipv6); + if(r != 0) { + printf("*** ERROR ***\n"); + } + return r; +} + +static int server(unsigned short port, const char * expected_file_name, int ipv6) +{ + int s, c; + int i; + struct sockaddr_storage server_addr; + socklen_t server_addrlen; + struct sockaddr_storage client_addr; + socklen_t client_addrlen; + pid_t pid; + int child = 0; + int status; + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); /*signal(SIGCHLD, handle_signal_chld);*/ diff --git a/miniupnpc/testminiwget.c b/miniupnpc/testminiwget.c index 5eb49ec..8465b4d 100644 --- a/miniupnpc/testminiwget.c +++ b/miniupnpc/testminiwget.c @@ -1,7 +1,7 @@ -/* $Id: testminiwget.c,v 1.5 2016/01/24 17:24:36 nanard Exp $ */ +/* $Id: testminiwget.c,v 1.6 2017/11/02 16:52:37 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2005-2016 Thomas Bernard + * Copyright (c) 2005-2017 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * */ diff --git a/miniupnpc/testminiwget.sh b/miniupnpc/testminiwget.sh index 690b405..ed112db 100755 --- a/miniupnpc/testminiwget.sh +++ b/miniupnpc/testminiwget.sh @@ -1,7 +1,7 @@ #!/bin/sh -# $Id: testminiwget.sh,v 1.13 2015/09/03 17:57:44 nanard Exp $ +# $Id: testminiwget.sh,v 1.14 2017/11/02 16:52:37 nanard Exp $ # project miniupnp : http://miniupnp.free.fr/ -# (c) 2011-2015 Thomas Bernard +# (c) 2011-2017 Thomas Bernard # # test program for miniwget.c # is usually invoked by "make check" @@ -44,6 +44,10 @@ while [ -z "$PORT" ]; do sleep 1 PORT=`cat $HTTPSERVEROUT | sed 's/Listening on port \([0-9]*\)/\1/' ` done +if [ "$PORT" = "*** ERROR ***" ]; then + echo "HTTP test server error" + exit 2 +fi echo "Test HTTP server is listening on $PORT" URL1="http://$ADDR:$PORT/index.html"