Interesting results for getservbyname() performance (and possible changes for /etc/services)

Nils Philippsen nphilipp at redhat.com
Thu Jan 12 13:10:22 UTC 2006


On Thu, 2006-01-12 at 06:36 -0500, Ignacio Vazquez-Abrams wrote:
> On Thu, 2006-01-12 at 12:02 +0100, Phil Knirsch wrote:
> > Now, i know and understand how and why glibc does the getservbyname() 
> > call as it does (namely, every time opening, reading and parsing the 
> > file). It neither caches calls nor does any other fancy stuff (how could 
> > it? The order in the file is arbitrary, so the only possibility is to do 
> > a linear read and parse of the file).
> 
> > Comments and suggestions are of course always welcome.
> 
> What about writing (or finding) a NS module that does caching? It can
> pull from a sorted bdb using a binary search, unless /etc/services is
> newer at which point it rebuilds the database. /etc/services almost
> *never* changes, so the rebuild speed shouldn't matter too much.

Well, it can't be done this way because NS modules are running with the
user's privileges. This would have to be handed off to a daemon with the
privileges necessary.

Nils
-- 
     Nils Philippsen    /    Red Hat    /    nphilipp at redhat.com
"They that can give up essential liberty to obtain a little temporary
 safety deserve neither liberty nor safety."     -- B. Franklin, 1759
 PGP fingerprint:  C4A8 9474 5C4C ADE3 2B8F  656D 47D8 9B65 6951 3011




More information about the devel mailing list