netcat-openbsd/serialized-handling-multiple-clients.patch
Vítězslav Čížek c0756e8f2c Accepting request 510980 from home:scarabeus_iv:branches:network:utilities
- Drop all patches that were never upstreamed:
  * connect-timeout.patch
  * dccp.patch
  * gcc-warnings.patch
  * getservbyname.patch
  * glib-strlcpy.patch
  * help-version-exit.patch
  * nc-1.84-udp_stop.patch
  * netcat-info.patch
  * netcat-openbsd-debian.patch
  * netcat-openbsd-examples.patch
  * netcat-openbsd-openbsd-compat.patch
  * no-strtonum.patch
  * pollhup.patch
  * quit-timer.patch
  * reuseaddr.patch
  * send-crlf.patch
  * silence-z.patch
  * socks-b64-prototype.patch
  * udp-scan-timeout.patch
  * verbose-message-to-stderr.patch
  * verbose-numeric-port.patch
- Switch to debian package to not waste resources on doing exactly
  the same.
- Switches URL for debian package
- Apply patches already prepared for debian package
  * port-to-linux-with-libsd.patch
  * compile-without-TLS-support.patch
  * connect-timeout.patch
  * get-sev-by-name.patch

OBS-URL: https://build.opensuse.org/request/show/510980
OBS-URL: https://build.opensuse.org/package/show/network:utilities/netcat-openbsd?expand=0&rev=16
2017-07-17 13:26:12 +00:00

78 lines
1.7 KiB
Diff

From: Aron Xu <aron@debian.org>
Date: Tue, 14 Feb 2012 23:02:00 +0800
Subject: serialized handling multiple clients
---
netcat.c | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
--- a/netcat.c
+++ b/netcat.c
@@ -664,7 +664,20 @@ main(int argc, char *argv[])
s = unix_bind(host, 0);
else
s = unix_listen(host);
- }
+ } else
+ s = local_listen(host, uport, hints);
+ if (s < 0)
+ err(1, NULL);
+
+ char* local;
+ if (family == AF_INET6)
+ local = ":::";
+ else
+ local = "0.0.0.0";
+ fprintf(stderr, "Listening on [%s] (family %d, port %d)\n",
+ host ?: local,
+ family,
+ *uport);
# if defined(TLS)
if (usetls) {
@@ -678,22 +691,7 @@ main(int argc, char *argv[])
# endif
/* Allow only one connection at a time, but stay alive. */
for (;;) {
- if (family != AF_UNIX)
- s = local_listen(host, uport, hints);
- if (s < 0)
- err(1, NULL);
-
- char* local;
- if (family == AF_INET6)
- local = "0.0.0.0";
- else if (family == AF_INET)
- local = ":::";
- else
- local = "unknown";
- fprintf(stderr, "Listening on [%s] (family %d, port %d)\n",
- host ?: local,
- family,
- *uport);
+
/*
* For UDP and -k, don't connect the socket, let it
* receive datagrams from multiple socket pairs.
@@ -760,15 +758,16 @@ main(int argc, char *argv[])
# endif
close(connfd);
}
- if (family != AF_UNIX)
+ if (kflag)
+ continue;
+ if (family != AF_UNIX) {
close(s);
+ }
else if (uflag) {
if (connect(s, NULL, 0) < 0)
err(1, "connect");
}
-
- if (!kflag)
- break;
+ break;
}
} else if (family == AF_UNIX) {
ret = 0;