aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-02-24 20:59:04 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-02-24 20:59:04 -0500
commit19d0f76c798aa3aa90b4652e8c6bb00a5b147b14 (patch)
treeef686a607f9493236abf340742158045f551fee2
parentc8a66458295aa0ae03929c8948ec102ff0683d4e (diff)
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 <rostedt@goodmis.org>
-rw-r--r--trace-listen.c9
1 files changed, 8 insertions, 1 deletions
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,
126 if (use_tcp) { 126 if (use_tcp) {
127 if (listen(sfd, backlog) < 0) 127 if (listen(sfd, backlog) < 0)
128 die("listen"); 128 die("listen");
129 peer_addr_len = sizeof(peer_addr);
129 cfd = accept(sfd, (struct sockaddr *)&peer_addr, &peer_addr_len); 130 cfd = accept(sfd, (struct sockaddr *)&peer_addr, &peer_addr_len);
131 if (cfd < 0)
132 die("accept");
130 close(sfd); 133 close(sfd);
131 sfd = cfd; 134 sfd = cfd;
132 } 135 }
133 136
134 do { 137 do {
135 peer_addr_len = sizeof(peer_addr);
136 /* TODO, make this copyless! */ 138 /* TODO, make this copyless! */
137 n = read(sfd, buf, page_size); 139 n = read(sfd, buf, page_size);
140 if (n < 0)
141 die("reading client");
138 if (!n) 142 if (!n)
139 break; 143 break;
140 /* UDP requires that we get the full size in one go */ 144 /* 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)
287 return; 291 return;
288 } 292 }
289 293
294 if (use_tcp)
295 printf("Using TCP for live connection\n");
296
290 /* Create the client file */ 297 /* Create the client file */
291 snprintf(buf, BUFSIZ, "%s.%s:%s.dat", output_file, node, port); 298 snprintf(buf, BUFSIZ, "%s.%s:%s.dat", output_file, node, port);
292 299