From: Bill Erickson Date: Mon, 24 Sep 2012 16:50:47 +0000 (-0400) Subject: Added content connect timeout X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ceb0735985666f7efee04cdaadfd3b00f6d2a409;p=evergreen%2Fpines.git Added content connect timeout Make tpac server-side added content lookups exit after a brief timeout when the apache module is unable to open a connection to its own top-level hostname (the virtualhost, apache->hostname). As noted in the code comments, even though we are using Net::Server::NB (non-blocking), it's only non-blocking in the sense of content retrieval, not in how it calls connect() under the covers. Signed-off-by: Bill Erickson Signed-off-by: Michael Peters --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 3ccbe649f5..6f15dab730 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -441,10 +441,20 @@ sub added_content_stage1 { if ($key) { $logger->debug("tpac: starting added content request for $key => $type"); - my $req = Net::HTTP::NB->new(Host => $self->apache->hostname); + # Net::HTTP::NB is non-blocking /after/ the initial connect() + # Passing Timeout=>1 ensures we wait no longer than 1 second to + # connect to the local Evergreen instance (i.e. ourself). + # Connecting to oneself should either be very fast (normal) + # or very slow (routing problems). + my $req = Net::HTTP::NB->new( + Host => $self->apache->hostname, + Timeout => 1 + ); if (!$req) { - $logger->warn("Unable to fetch added content from " . $self->apache->hostname . ": $@"); + $logger->warn("Unable to connect to " . + $self->apache->hostname . + " for added content lookup for $key: $@"); next; }