X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=bin%2Fldap-koha.pl;h=30c2c9e003fb21f2f937480e88f9e2b5c67b755f;hp=d50ebbca4655db00bb2134fb11ffee9ec87d3091;hb=9d36c5db63043dde1160fae994845f2913f42ac7;hpb=97697527827da534e72c5ed16d577df9ff21f837 diff --git a/bin/ldap-koha.pl b/bin/ldap-koha.pl index d50ebbc..30c2c9e 100755 --- a/bin/ldap-koha.pl +++ b/bin/ldap-koha.pl @@ -8,16 +8,26 @@ use IO::Socket; use lib 'lib'; use LDAP::Koha; -my $port = 2389; +my $debug = $ENV{DEBUG} || 0; + +BEGIN { + $SIG{'__WARN__'} = sub { + my $level = $1 if $_[0] =~ m/^(#+)/; + return if defined($level) && length($level) > $debug; + + warn join("\n", @_); + }; +} +my $listen = shift @ARGV || 'localhost:2389'; my $sock = IO::Socket::INET->new( Listen => 5, Proto => 'tcp', Reuse => 1, - LocalPort => $port, -) || die; + LocalAddr => $listen, +) || die "can't listen to $listen $!"; -warn "# listening on $port"; +warn "# listening on $listen"; my $sel = IO::Select->new($sock); my %Handlers; @@ -26,6 +36,7 @@ while (my @ready = $sel->can_read) { if ($fh == $sock) { # let's create a new socket my $psock = $sock->accept; + $psock->sockopt(SO_KEEPALIVE,1); $sel->add($psock); $Handlers{*$psock} = LDAP::Koha->new($psock); } else {