Nmap Development mailing list archives

Re: [PATCH] Dramatically reduce # of fopen()s and fclose()s in nbase_rnd.c


From: Kris Katterjohn <katterjohn () gmail com>
Date: Sat, 16 Dec 2006 10:47:51 -0600

Dmitry V. Levin wrote:
On Fri, Dec 15, 2006 at 11:43:38AM -0600, Kris Katterjohn wrote:
This simple patch dramatically reduces the number of fopen()s and
fclose()s used when getting random numbers from nbase_rnd.c by keeping
the rng device open.

Before:

# strace nmap -p- localhost 2>&1 | grep 'open("/dev/[au]*random"' | wc
    512    3584   31744

After:

# strace ./nmap -p- localhost 2>&1 | grep 'open("/dev/[au]*random"' | wc
      2      14     124

You can also compare "strace -c" output to estimate effect of the change.


Oh cool, thanks. The only problem with trying to compare the difference
like this is that fopen() has more "stuff" in it than an open() call. If
it's just like the one in K&R (Ch. 8 or 9, I believe), it might not be a
big deal, but with what's probably in glibc, for example, it's likely
bloated -- or at least "feature-rich" :)

Of course I _am_ the one who initially counted the open()s, but I just
wanted to see how many times fopen() is called, along with the extra
stuff in it.

Thanks,
Kris Katterjohn

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


Current thread: