From 3d92c648ca0f09aa7db56eb98bea792083d677b1 Mon Sep 17 00:00:00 2001
From: Julian Maurice <julian.maurice@biblibre.com>
Date: Wed, 13 Nov 2013 14:21:40 +0100
Subject: [PATCH] Fix C4::Context::Zconn()

http://bugs.koha-community.org/show_bug.cgi?id=7419
---
 C4/Context.pm |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/C4/Context.pm b/C4/Context.pm
index 3914420..f61bf14 100644
--- a/C4/Context.pm
+++ b/C4/Context.pm
@@ -693,8 +693,8 @@ sub Zconn {
     my $auth=shift;
     my $piggyback=shift;
     my $syntax=shift;
-    if ( defined($context->{"Zconn"}->{$server}) && (0 == $context->{"Zconn"}->{$server}->errcode()) ) {
-        return $context->{"Zconn"}->{$server};
+    if ( defined($context->{"Zconn"}->{$server}->{$async}) && (0 == $context->{"Zconn"}->{$server}->{$async}->errcode()) ) {
+        return $context->{"Zconn"}->{$server}->{$async};
     # No connection object or it died. Create one.
     }else {
         # release resources if we're closing a connection and making a new one
@@ -703,12 +703,12 @@ sub Zconn {
         # and make a new one, particularly for a batch job.  However, at
         # first glance it does not look like there's a way to easily check
         # the basic health of a ZOOM::Connection
-        $context->{"Zconn"}->{$server}->destroy() if defined($context->{"Zconn"}->{$server});
+        $context->{"Zconn"}->{$server}->{$async}->destroy() if defined($context->{"Zconn"}->{$server}->{$async});
 
-        $context->{"Zconn"}->{$server} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
-        $context->{ Zconn }->{ $server }->option(
+        $context->{"Zconn"}->{$server}->{$async} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
+        $context->{ Zconn }->{ $server }->{$async}->option(
             preferredRecordSyntax => C4::Context->preference("marcflavour") );
-        return $context->{"Zconn"}->{$server};
+        return $context->{"Zconn"}->{$server}->{$async};
     }
 }
 
-- 
1.7.10.4