2017-07-17 15:26:12 +02:00
|
|
|
From: Aron Xu <aron@debian.org>
|
|
|
|
Date: Tue, 14 Feb 2012 23:02:00 +0800
|
|
|
|
Subject: serialized handling multiple clients
|
|
|
|
|
|
|
|
---
|
2019-09-09 20:51:34 +02:00
|
|
|
netcat.c | 17 ++++++++---------
|
|
|
|
1 file changed, 8 insertions(+), 9 deletions(-)
|
2017-07-17 15:26:12 +02:00
|
|
|
|
|
|
|
--- a/netcat.c
|
|
|
|
+++ b/netcat.c
|
2019-09-09 20:51:34 +02:00
|
|
|
@@ -707,7 +707,10 @@ main(int argc, char *argv[])
|
2017-07-17 15:26:12 +02:00
|
|
|
s = unix_bind(host, 0);
|
|
|
|
else
|
|
|
|
s = unix_listen(host);
|
2019-09-09 20:51:34 +02:00
|
|
|
- }
|
2017-07-17 15:26:12 +02:00
|
|
|
+ } else
|
|
|
|
+ s = local_listen(host, uport, hints);
|
|
|
|
+ if (s < 0)
|
|
|
|
+ err(1, NULL);
|
|
|
|
|
|
|
|
# if defined(TLS)
|
2019-09-09 20:51:34 +02:00
|
|
|
if (usetls) {
|
|
|
|
@@ -721,13 +724,6 @@ main(int argc, char *argv[])
|
2017-07-17 15:26:12 +02:00
|
|
|
# endif
|
|
|
|
/* Allow only one connection at a time, but stay alive. */
|
|
|
|
for (;;) {
|
2018-11-14 14:18:05 +01:00
|
|
|
- if (family != AF_UNIX) {
|
|
|
|
- if (s != -1)
|
|
|
|
- close(s);
|
2017-07-17 15:26:12 +02:00
|
|
|
- s = local_listen(host, uport, hints);
|
2018-11-14 14:18:05 +01:00
|
|
|
- }
|
2017-07-17 15:26:12 +02:00
|
|
|
- if (s < 0)
|
|
|
|
- err(1, NULL);
|
2018-11-14 14:18:05 +01:00
|
|
|
if (uflag && kflag) {
|
|
|
|
/*
|
|
|
|
* For UDP and -k, don't connect the socket,
|
2019-09-09 20:51:34 +02:00
|
|
|
@@ -804,8 +800,11 @@ main(int argc, char *argv[])
|
2017-07-17 15:26:12 +02:00
|
|
|
err(1, "connect");
|
|
|
|
}
|
2018-11-14 14:18:05 +01:00
|
|
|
|
2017-07-17 15:26:12 +02:00
|
|
|
- if (!kflag)
|
2018-11-14 14:18:05 +01:00
|
|
|
+ if (!kflag) {
|
|
|
|
+ if (s != -1)
|
|
|
|
+ close(s);
|
|
|
|
break;
|
|
|
|
+ }
|
2017-07-17 15:26:12 +02:00
|
|
|
}
|
|
|
|
} else if (family == AF_UNIX) {
|
|
|
|
ret = 0;
|