From 19d0f76c798aa3aa90b4652e8c6bb00a5b147b14 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Wed, 24 Feb 2010 17:59:04 -0800 Subject: trace-cmd: Fix accept in listen for tcp client read The peer_addr_len was not being initialized for use with accept in the TCP version of the client read. This caused the accept to fail. Also added error checks and printing of the fact that the client requested using TCP. Signed-off-by: Steven Rostedt --- trace-listen.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/trace-listen.c b/trace-listen.c index 47e98f4..9a1981b 100644 --- a/trace-listen.c +++ b/trace-listen.c @@ -126,15 +126,19 @@ static void process_udp_child(int sfd, const char *host, const char *port, if (use_tcp) { if (listen(sfd, backlog) < 0) die("listen"); + peer_addr_len = sizeof(peer_addr); cfd = accept(sfd, (struct sockaddr *)&peer_addr, &peer_addr_len); + if (cfd < 0) + die("accept"); close(sfd); sfd = cfd; } do { - peer_addr_len = sizeof(peer_addr); /* TODO, make this copyless! */ n = read(sfd, buf, page_size); + if (n < 0) + die("reading client"); if (!n) break; /* UDP requires that we get the full size in one go */ @@ -287,6 +291,9 @@ static void process_client(const char *node, const char *port, int fd) return; } + if (use_tcp) + printf("Using TCP for live connection\n"); + /* Create the client file */ snprintf(buf, BUFSIZ, "%s.%s:%s.dat", output_file, node, port); -- cgit v1.2.2