use select as default nsock engine

This commit is contained in:
Michal Hlavinka 2013-01-04 12:54:42 +01:00
parent f4108b7021
commit 5b830ce740
2 changed files with 15 additions and 34 deletions

View File

@ -1,34 +1,12 @@
diff -up nmap-6.01/ncat/ncat_connect.c.ncat_reg_stdin nmap-6.01/ncat/ncat_connect.c diff -up nmap-6.01/ncat/ncat_main.c.noepoll nmap-6.01/ncat/ncat_main.c
--- nmap-6.01/ncat/ncat_connect.c.ncat_reg_stdin 2012-03-01 07:53:35.000000000 +0100 --- nmap-6.01/ncat/ncat_main.c.noepoll 2013-01-04 12:50:18.670295473 +0100
+++ nmap-6.01/ncat/ncat_connect.c 2012-08-08 18:34:36.971502138 +0200 +++ nmap-6.01/ncat/ncat_main.c 2013-01-04 12:50:18.692295660 +0100
@@ -458,10 +458,30 @@ bail: @@ -280,6 +280,8 @@ int main(int argc, char *argv[])
return -1; #ifdef WIN32
} windows_init();
#endif
+
+ nsock_set_default_engine("select");
+#if defined(LINUX) while (1) {
+static int stdin_is_reg(void) { /* handle command line arguments */
+ struct stat buf;
+
+ if (fstat(STDIN_FILENO, &buf) < 0)
+ fatal("fstat(): %s", strerror(errno));
+
+ return S_ISREG(buf.st_mode);
+}
+#endif
+
int ncat_connect(void) {
nsock_pool mypool;
int rc;
+#if defined(LINUX)
+ /* -- Hack!!
+ * epoll(7) doesn't support regular files (e.g.: ncat < file.c)
+ * If we detect that STDIN is a regular file, then we enforce
+ * the use of the select-based engine. */
+ //if (stdin_is_reg())
+ nsock_set_default_engine("select");
+#endif
+
/* Create an nsock pool */
if ((mypool = nsp_new(NULL)) == NULL)
bye("Failed to create nsock_pool.");

View File

@ -4,7 +4,7 @@ Name: nmap
Epoch: 2 Epoch: 2
Version: 6.01 Version: 6.01
#global prerelease TEST5 #global prerelease TEST5
Release: 9%{?dist} Release: 10%{?dist}
# nmap is GPLv2 # nmap is GPLv2
# zenmap is GPLv2 and LGPLv2+ (zenmap/higwidgets) and GPLv2+ (zenmap/radialnet) # zenmap is GPLv2 and LGPLv2+ (zenmap/higwidgets) and GPLv2+ (zenmap/radialnet)
# libdnet-stripped is BSD (advertising clause rescinded by the Univ. of California in 1999) with some parts as Public Domain (crc32) # libdnet-stripped is BSD (advertising clause rescinded by the Univ. of California in 1999) with some parts as Public Domain (crc32)
@ -220,6 +220,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/xnmap.1.gz %{_mandir}/man1/xnmap.1.gz
%changelog %changelog
* Fri Jan 04 2013 Michal Hlavinka <mhlavink@redhat.com> - 2:6.01-10
- use select as default nsock engine
* Thu Nov 29 2012 Michal Hlavinka <mhlavink@redhat.com> - 2:6.01-9 * Thu Nov 29 2012 Michal Hlavinka <mhlavink@redhat.com> - 2:6.01-9
- do not use strict aliasing - do not use strict aliasing