t/compat/conn_rec.t failure in trunk with Apache 2.4

Niko Tyni <[email protected]>
Newsgroups gmane.comp.apache.mod-perl.devel
Message-ID <[email protected]>
Hi,

I'm trying to get the current mod_perl trunk to build on Debian unstable
(with Apache 2.4.10 and Perl 5.18.2), and I'm seeing a failure in
t/compat/conn_rec.t. It's getting an internal server error at test 3,
with this in t/logs/error_log:

 [Thu Aug 07 14:15:39.916269 2014] [perl:error] [pid 19060:tid 140108267251456] [client 127.0.0.1:36626] overriding Apache2::Connection::remote_addr didn't return a CODE ref at /home/niko/tmp/libapache2-mod-perl2/blib/lib/Apache2/compat.pm line 252.\n

So it's the remote_addr vs. client_addr thing again.

The test used to work with the httpd24 branch at r1449661, and it
looks like it broke with r1497279, which restored 2.2 compatibility
in lib/Apache2/compat.pm

 http://svn.apache.org/viewvc?view=revision&revision=1497279

If I understand this correctly, Apache2::compat is supposed to provide
mod_perl 1.0 backward compatibility, so we want to offer remote_addr()
there even with Apache 2.4. Does the attached patch make sense? It works
for me on 2.4 and I'd expect it to work with 2.2 too (but I haven't
verified that.)
-- 
Niko Tyni   [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
0001-Restore-httpd-2.4-compatibility-in-lib-Apache2-compa.patch (text/x-diff, 1.2 KB)
From 84a28e4c1a673742673a80fb8eb64bde2e8ff54c Mon Sep 17 00:00:00 2001
From: Niko Tyni <[email protected]>
Date: Thu, 7 Aug 2014 00:18:23 +0300
Subject: [PATCH] Restore httpd-2.4 compatibility in lib/Apache2/compat.pm

This fixes t/compat/conn_rec.t. failures with Apache 2.4,
broken with r1497279.

Apache2::compat is supposed to provide mod_perl 1.0 backward
compatibility, so we want to offer remote_addr() there even with
Apache 2.4.
---
 lib/Apache2/compat.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/Apache2/compat.pm b/lib/Apache2/compat.pm
index e7e2c0f..9c3eccd 100644
--- a/lib/Apache2/compat.pm
+++ b/lib/Apache2/compat.pm
@@ -150,7 +150,12 @@ EOI
     require Apache2::Connection;
     require APR::SockAddr;
     require Socket;
-    my $orig_sub = *Apache2::Connection::remote_addr{CODE};
+    my $orig_sub;
+    if (defined *Apache2::Connection::client_addr{CODE}) { # httpd-2.4
+        $orig_sub = *Apache2::Connection::client_addr{CODE};
+    } else { # httpd-2.2
+        $orig_sub = *Apache2::Connection::remote_addr{CODE};
+    }
     *Apache2::Connection::remote_addr = sub {
         my $c = shift;
         if (@_) {
-- 
2.0.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.