From: Bill Erickson Date: Mon, 24 Sep 2012 21:12:11 +0000 (-0400) Subject: TPAC added content lookup uses local server address X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4115d24228d0de21a2c325838d4a7a601d238bd1;p=evergreen%2Fpines.git TPAC added content lookup uses local server address Use the current Apache server's IP address instead of apache->hostname to determine where to route TPAC added content lookups. This allows the server to handle the added content lookup locally instead of having to route out and back into the cluster. Continue using apache->hostname as the Host header to ensure the proper virtualhost is used once the request is received. 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 6f15dab730..a70db54438 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -433,6 +433,15 @@ sub added_content_stage1 { my $key = $self->get_ac_key($rec_id); ($key = $key->{value}) =~ s/^\s+//g if $key; + # Connect to this machine's IP address, using the same + # Host with which our caller used to connect to us. + # This avoids us having to route out of the cluster + # and back in to reach the top-level virtualhost. + my $ac_addr = $ENV{SERVER_ADDR}; + my $ac_host = $self->apache->hostname; + + $logger->info("tpac: added content connecting to $ac_addr / $ac_host"); + $ctx->{added_content} = {}; for my $type (@$ac_types) { $ctx->{added_content}->{$type} = {content => ''}; @@ -446,14 +455,12 @@ sub added_content_stage1 { # 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 - ); + + my $req = Net::HTTP::NB->new(Host => $ac_addr, Timeout => 1); + $req->host($self->apache->hostname); if (!$req) { - $logger->warn("Unable to connect to " . - $self->apache->hostname . + $logger->warn("Unable to connect to $ac_addr / $ac_host". " for added content lookup for $key: $@"); next; }