Fix potential address-in-use errors in epoll_server test

Wait for all the children to exit before server exits to release all the
resource used by the test.
This commit is contained in:
He Sun 2020-05-12 14:34:57 +08:00 committed by Tate, Hongliang Tian
parent a6d97d5b4f
commit aed572064b

@ -9,6 +9,7 @@
#include <sys/epoll.h> #include <sys/epoll.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h>
#include "test.h" #include "test.h"
@ -142,6 +143,14 @@ int test_ip_socket() {
} }
} }
// Wait for all the children to exit
for (int i = 0; i < proc_num; i++) {
if (wait(NULL) < 0) {
close_files(2, server_fd, epfd);
THROW_ERROR("failed to wait");
}
}
close_files(2, server_fd, epfd); close_files(2, server_fd, epfd);
return 0; return 0;
} }