|
From: Jiri J. <jja...@re...> - 2013-10-07 11:32:12
|
This change makes do_connect wait (linger) until all packets
in a connection are sent. Some tests rely on the fact that
the connection is already closed when do_connect returns (exits).
If this is not ensured, a race condition happens between FIN-ACK
packets and audit, with audit winning most of the time, resulting
in packets not being in audit log when augrok looks for them,
making the tests fail.
Signed-off-by: Jiri Jaburek <jja...@re...>
---
audit-test/utils/bin/do_connect.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/audit-test/utils/bin/do_connect.c b/audit-test/utils/bin/do_connect.c
index a430615..d88c058 100644
--- a/audit-test/utils/bin/do_connect.c
+++ b/audit-test/utils/bin/do_connect.c
@@ -21,6 +21,7 @@ int main(int argc, char **argv)
struct addrinfo *host = NULL;
struct addrinfo addr_hints;
int sock;
+ struct linger so_linger = { .l_onoff = 1, .l_linger = INT_MAX };
if (argc != 4) {
fprintf(stderr, "Usage:\n%s <host> tcp|udp <port>\n", argv[0]);
@@ -43,10 +44,15 @@ int main(int argc, char **argv)
if (sock < 0)
return TEST_ERROR;
+ setsockopt(sock, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger));
+
errno = 0;
rc = connect(sock, host->ai_addr, host->ai_addrlen);
result = (rc < 0 ? TEST_FAIL : TEST_SUCCESS);
printf("%d %d %d\n", result, result ? errno : rc, getpid());
+
+ shutdown(sock, SHUT_RDWR);
+ close(sock);
return result;
}
--
1.8.3.1
|