logo       

[patch] enabling PerlPreConnectionHandler: msg#00071

Subject: [patch] enabling PerlPreConnectionHandler
Any reason why PerlPreConnectionHandler is not enabled? The following patch enables it and adds support to the test suite.

I currently chose to ignore 'void *csd' in the callback, since I'm not sure what can be done with it on the perl land.

Index: Apache-Test/lib/Apache/TestConfigPerl.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.59
diff -u -r1.59 TestConfigPerl.pm
--- Apache-Test/lib/Apache/TestConfigPerl.pm    13 Dec 2002 10:58:40 -0000      
1.59
+++ Apache-Test/lib/Apache/TestConfigPerl.pm    31 Dec 2002 06:10:57 -0000
@@ -148,15 +148,21 @@
         $self->server->version_of(\%sethandler_modperl);
 }

+sub set_connection_handler {
+    my($self, $module, $args) = @_;
+    my $port = $self->new_vhost($module);
+    $self->postamble(Listen => $port);
+}
+
 my %add_hook_config = (
-    Response => \&set_handler,
-    ProcessConnection => sub { my($self, $module, $args) = @_;
-                               my $port = $self->new_vhost($module);
-                               $self->postamble(Listen => $port); },
+    Response          => \&set_handler,
+    ProcessConnection => \&set_connection_handler,
+    PreConnection     => \&set_connection_handler,
 );

 my %container_config = (
     ProcessConnection => \&vhost_container,
+    PreConnection     => \&vhost_container,
 );

 sub location_container {
@@ -279,7 +285,7 @@
 $hooks{Protocol} = 'ProcessConnection';
 $hooks{Filter}   = 'OutputFilter';

-my @extra_subdirs = qw(Response Protocol Hooks Filter);
+my @extra_subdirs = qw(Response Protocol PreConnection Hooks Filter);

 # add the subdirs to @INC early, in case mod_perl is started earlier
 sub configure_pm_tests_inc {
Index: src/modules/perl/modperl_callback.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_callback.c,v
retrieving revision 1.50
diff -u -r1.50 modperl_callback.c
--- src/modules/perl/modperl_callback.c 23 May 2002 05:55:35 -0000      1.50
+++ src/modules/perl/modperl_callback.c 31 Dec 2002 06:10:58 -0000
@@ -153,6 +153,7 @@
             modperl_env_request_populate(aTHX_ r);
         }
         break;
+      case MP_HANDLER_TYPE_PRE_CONNECTION:
       case MP_HANDLER_TYPE_CONNECTION:
         modperl_handler_make_args(aTHX_ &av_args,
                                   "Apache::Connection", c, NULL);
@@ -220,7 +221,9 @@

 int modperl_callback_pre_connection(int idx, conn_rec *c, void *csd)
 {
-    return DECLINED; /*XXX*/
+ return modperl_callback_run_handlers(idx, MP_HANDLER_TYPE_PRE_CONNECTION,
+                                         NULL, c, c->base_server,
+                                         NULL, NULL, NULL);
 }

 void modperl_callback_process(int idx, apr_pool_t *p, server_rec *s)
Index: src/modules/perl/modperl_config.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.c,v
retrieving revision 1.60
diff -u -r1.60 modperl_config.c
--- src/modules/perl/modperl_config.c   12 Dec 2002 10:05:08 -0000      1.60
+++ src/modules/perl/modperl_config.c   31 Dec 2002 06:10:58 -0000
@@ -254,6 +254,9 @@
     for (i=0; i < MP_HANDLER_NUM_PROCESS; i++) {
         merge_handlers(MpSrvMERGE_HANDLERS, handlers_process[i]);
     }
+    for (i=0; i < MP_HANDLER_NUM_PRE_CONNECTION; i++) {
+        merge_handlers(MpSrvMERGE_HANDLERS, handlers_pre_connection[i]);
+    }
     for (i=0; i < MP_HANDLER_NUM_CONNECTION; i++) {
         merge_handlers(MpSrvMERGE_HANDLERS, handlers_connection[i]);
     }
Index: src/modules/perl/modperl_handler.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_handler.c,v
retrieving revision 1.14
diff -u -r1.14 modperl_handler.c
--- src/modules/perl/modperl_handler.c  6 Dec 2002 07:58:21 -0000       1.14
+++ src/modules/perl/modperl_handler.c  31 Dec 2002 06:10:58 -0000
@@ -220,6 +220,11 @@
         }
         set_desc(per_srv);
         break;
+      case MP_HANDLER_TYPE_PRE_CONNECTION:
+        avp = &scfg->handlers_pre_connection[idx];
+        check_modify(connection);
+        set_desc(connection);
+        break;
       case MP_HANDLER_TYPE_CONNECTION:
         avp = &scfg->handlers_connection[idx];
         check_modify(connection);


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxxxxxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe