提交 f222c37c 编写于 作者: D David Ahern 提交者: Jakub Kicinski

selftests: Use separate stdout and stderr buffers in nettest

When a single instance of nettest is doing both client and
server modes, stdout and stderr messages can get interlaced
and become unreadable. Allocate a new set of buffers for the
child process handling server mode.
Signed-off-by: NDavid Ahern <dsahern@gmail.com>
Signed-off-by: NJakub Kicinski <kuba@kernel.org>
上级 6469403c
...@@ -1707,9 +1707,28 @@ static char *random_msg(int len) ...@@ -1707,9 +1707,28 @@ static char *random_msg(int len)
static int ipc_child(int fd, struct sock_args *args) static int ipc_child(int fd, struct sock_args *args)
{ {
char *outbuf, *errbuf;
int rc = 1;
outbuf = malloc(4096);
errbuf = malloc(4096);
if (!outbuf || !errbuf) {
fprintf(stderr, "server: Failed to allocate buffers for stdout and stderr\n");
goto out;
}
setbuffer(stdout, outbuf, 4096);
setbuffer(stderr, errbuf, 4096);
server_mode = 1; /* to tell log_msg in case we are in both_mode */ server_mode = 1; /* to tell log_msg in case we are in both_mode */
return do_server(args, fd); rc = do_server(args, fd);
out:
free(outbuf);
free(errbuf);
return rc;
} }
static int ipc_parent(int cpid, int fd, struct sock_args *args) static int ipc_parent(int cpid, int fd, struct sock_args *args)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册