You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2002/12/31 07:15:39 UTC

[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@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] enabling PerlPreConnectionHandler

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:
> On Tue, 31 Dec 2002, Stas Bekman wrote:
> 
> 
>>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.
> 
> 
> i think that's the only reason it wasn't added yet, too lazy to change 
> the generation code to deal with handling that argument.  fine to ignore 
> it for now, +1 on your patch.

committed. added a note to the STATUS file so we don't forget to handle 
that arg in the future.

I'll add a few tests later. I think setting up filters and 
datastructures in the connection record would be good tests.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] enabling PerlPreConnectionHandler

Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 31 Dec 2002, Stas Bekman wrote:

> 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.

i think that's the only reason it wasn't added yet, too lazy to change 
the generation code to deal with handling that argument.  fine to ignore 
it for now, +1 on your patch.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org