examples/nettest: Fix a couple of crazy long delays that may make you think something is broken. In main, add a wait for the server to exit

This commit is contained in:
Gregory Nutt 2015-08-27 11:46:42 -06:00
parent a7853cdc89
commit ed2ccad735
2 changed files with 14 additions and 3 deletions

View File

@ -40,6 +40,7 @@
#include "config.h"
//#include <nuttx/config.h>
#include <sys/wait.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
@ -202,8 +203,11 @@ int main(int argc, FAR char *argv[])
int nettest_main(int argc, char *argv[])
#endif
{
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK)
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
pid_t child;
#ifdef CONFIG_SCHED_WAITPID
int statloc;
#endif
#endif
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
@ -224,7 +228,7 @@ int nettest_main(int argc, char *argv[])
return EXIT_FAILURE;
}
usleep(500*10000);
usleep(500*1000);
#elif defined(CONFIG_EXAMPLES_NETTEST_SERVER)
/* Then perform the server side of the test on this thread */
@ -239,5 +243,10 @@ int nettest_main(int argc, char *argv[])
send_client();
#endif
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(CONFIG_SCHED_WAITPID)
printf("main: Waiting for the server to exit\n");
(void)waitpid(child, &statloc, 0);
#endif
return EXIT_SUCCESS;
}

View File

@ -178,6 +178,7 @@ void recv_server(void)
printf("server: The client broke the connection\n");
goto errout_with_acceptsd;
}
printf("Received %d bytes\n", nbytesread);
}
#else
@ -245,9 +246,10 @@ void recv_server(void)
#if 1 /* Do it for all platforms */
printf("server: Wait before closing\n");
sleep(60);
sleep(2);
#endif
printf("server: Terminating\n");
close(listensd);
close(acceptsd);
free(buffer);