projects
/
mirror
/
userdir-ldap.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Made fingerserv forking; much faster this way...
[mirror/userdir-ldap.git]
/
ud-fingerserv
diff --git
a/ud-fingerserv
b/ud-fingerserv
index
915715d
..
67fc24f
100755
(executable)
--- a/
ud-fingerserv
+++ b/
ud-fingerserv
@@
-1,5
+1,5
@@
#!/usr/bin/perl
#!/usr/bin/perl
-# $Id: ud-fingerserv,v 1.
2 1999/10/05 02:54:2
9 tausq Exp $
+# $Id: ud-fingerserv,v 1.
3 1999/10/14 04:28:5
9 tausq Exp $
# (c) 1999 Randolph Chung. Licensed under the GPL. <tausq@debian.org>
# (c) 1999 Randolph Chung. Licensed under the GPL. <tausq@debian.org>
@@
-7,6
+7,7
@@
use lib 'web';
use strict vars;
#use Apache::Registry;
use IO::Socket;
use strict vars;
#use Apache::Registry;
use IO::Socket;
+use POSIX qw(:sys_wait_h);
use Util;
use Net::LDAP qw(:all);
use Util;
use Net::LDAP qw(:all);
@@
-29,7
+30,13
@@
sub DieHandler {
$ldap->unbind if (defined($ldap));
}
$ldap->unbind if (defined($ldap));
}
+sub Reaper {
+ 1 until (-1 == waitpid(-1, WNOHANG));
+ $SIG{CHLD} = \&Reaper;
+}
+
$SIG{__DIE__} = \&DieHandler;
$SIG{__DIE__} = \&DieHandler;
+$SIG{CHLD} = \&Reaper;
$ldap = Net::LDAP->new($config{ldaphost}) || &Util::HTMLError($!);
$mesg;
$ldap = Net::LDAP->new($config{ldaphost}) || &Util::HTMLError($!);
$mesg;
@@
-43,10
+50,14
@@
my $server = IO::Socket::INET->new(Proto => 'tcp',
die "Cannot listen on finger port" unless $server;
print "[Server listening for connections]\n";
die "Cannot listen on finger port" unless $server;
print "[Server listening for connections]\n";
-my ($mesg, %entries, $dn, $key);
+my ($mesg, %entries, $dn, $key
, $pid
);
my $client;
while ($client = $server->accept()) {
my $client;
while ($client = $server->accept()) {
+ next if $pid = fork; # parent
+ die "fork: $!" unless defined $pid;
+
+ # child
$client->autoflush(1);
my $hostinfo = gethostbyaddr($client->peeraddr, AF_INET);
printf "[Connect from %s]\n", $hostinfo || $client->peerhost;
$client->autoflush(1);
my $hostinfo = gethostbyaddr($client->peeraddr, AF_INET);
printf "[Connect from %s]\n", $hostinfo || $client->peerhost;
@@
-54,7
+65,7
@@
while ($client = $server->accept()) {
$query =~ s/[^\/,0-9a-z]//gi; # be paranoid about input
my ($uid, $fields) = split(/\//, $query, 2);
$query =~ s/[^\/,0-9a-z]//gi; # be paranoid about input
my ($uid, $fields) = split(/\//, $query, 2);
- print "Looking up $uid at $config{basedn}, uid=$uid\n";
+
#
print "Looking up $uid at $config{basedn}, uid=$uid\n";
$mesg = $ldap->search(base => $config{basedn}, filter => "uid=$uid");
$mesg->code && die $mesg->error;
$mesg = $ldap->search(base => $config{basedn}, filter => "uid=$uid");
$mesg->code && die $mesg->error;
@@
-87,6
+98,9
@@
while ($client = $server->accept()) {
}
}
$client->close;
}
}
$client->close;
+ exit;
+} continue {
+ $client->close;
}
$ldap->unbind;
}
$ldap->unbind;