On Mon, Oct 08, 2007 at 04:35:22PM -0700, Tom Eastep wrote:
> Andrew Suffield wrote:
> > I find myself wondering why buildports.pl exists at all. Tom, did you
> > have anything in particular in mind? I observe the following on my
> > (admittedly pretty fast) desktop:
> > ...
> 
> Not all distributions include a tiny /etc/services (like Debian does).
> 
> gateway:~ # wc -l /etc/services
> 14705 /etc/services
> gateway:~ # time shorewall restart
> Compiling...
> Shorewall configuration compiled to /root/shorewall/.restart
> Restarting Shorewall....
> done.
> 
> real    0m1.131s
> user    0m0.404s
> sys     0m0.304s
> gateway:~ #  # time /usr/share/shorewall-perl/buildports.pl > /dev/null
> 
> real    0m0.412s
> user    0m0.368s
> sys     0m0.040s
> gateway:~ #

Well, given that glibc is parsing both those files during the startup
of most significant network applications and I doubt SuSE would accept
that big a penalty, my working theory is that your perl parser is just
slow compared to the libc one (likely, since C code is usually much
faster than perl). There's no good reason for reimplementing the libc
logic anyway, and you should be letting libc handle it just to get
nsswitch.conf support. Try the attached patch which switches it over
to using perl's builtin interface to NSS, see if that helps.
--- buildports.pl	2007-08-26 17:51:49.000000000 +0100
+++ buildports-sane.pl	2007-10-09 00:40:46.000000000 +0100
@@ -70,17 +70,6 @@
 #
 #            E x e c u t i o n   B e g i n s   H e r e
 #
-set_config_path( '/etc' );
-
-our $dir = $ARGV[0] || '/etc';
-
-$dir =~ s|/+$|| unless $dir eq '/';
-#
-# Open the files before we do anything else
-#
-open_file "$dir/services" or fatal_error "$dir/services is empty";
-
-push_open "$dir/protocols" or fatal_error "$dir/protocols is empty";
 
 our $date = localtime;
 
@@ -131,8 +120,8 @@
 our %protocols = (
 EOF
 
-while ( read_a_line1 ) {
-    my ( $proto1, $number, @aliases ) = split_line( 2, 10, '/etc/protocols entry');
+while ( my ($proto1, $aliases, $number, undef) = getprotoent() ) {
+    my @aliases = split(' ', $aliases);
 
     print_it( $proto1, $number );
 
@@ -142,16 +131,12 @@
     }
 }
 
-pop_open;
-
 print "\t\t );\n\n";
 
 print "our %services  = (\n";
 
-while ( read_a_line1 ) {
-    my ( $name1, $proto_number, @names ) = split_line( 2, 10, '/etc/services entry');
-
-    my ( $number, $proto ) = split '/', $proto_number;
+while ( my ($name1, $aliases, $number, $proto) = getservent() ) {
+    my @names = split(' ', $aliases);
 
     next unless $proto && ($proto eq 'tcp' || $proto eq 'udp');
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Shorewall-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shorewall-devel

Reply via email to