aboutsummaryrefslogtreecommitdiff
path: root/tests/sockets/test_sockets_partial_server.c
diff options
context:
space:
mode:
authorAnthony Pesch <inolen@gmail.com>2013-08-30 16:52:52 -0700
committerAnthony Pesch <inolen@gmail.com>2013-08-30 16:53:05 -0700
commit5cf189f76e6e0ebb5d0e4866e066ac26da7ccbb6 (patch)
treebbc72b05c0854b083329e71f93c43685104f1a37 /tests/sockets/test_sockets_partial_server.c
parent19d175c00a94e66f96b2535fae7b4d4fad3c2248 (diff)
don't close client sockets by default in echo server enabling TCP teardown to succeed
Diffstat (limited to 'tests/sockets/test_sockets_partial_server.c')
-rw-r--r--tests/sockets/test_sockets_partial_server.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/sockets/test_sockets_partial_server.c b/tests/sockets/test_sockets_partial_server.c
index 44ad40a3..19f7f2af 100644
--- a/tests/sockets/test_sockets_partial_server.c
+++ b/tests/sockets/test_sockets_partial_server.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -18,8 +19,14 @@ int serverfd = 0;
int clientfd = 0;
void cleanup() {
- if (serverfd) close(serverfd);
- if (clientfd) close(clientfd);
+ if (serverfd) {
+ close(serverfd);
+ serverfd = 0;
+ }
+ if (clientfd) {
+ close(clientfd);
+ clientfd = 0;
+ }
}
void do_send(int sockfd) {
@@ -86,7 +93,7 @@ int main() {
int res;
atexit(cleanup);
- //signal(SIGTERM, cleanup);
+ signal(SIGTERM, cleanup);
// create the socket
serverfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);