ok, but I don't understand why this can't follow the same mechanics of attributes, since they work just fine for the other stuff.

It's not the same. Currently we use attributes to learn whether the handler is designed for Request or Connection. But we already know the name of the handler. So we don't have to go through all $__PACKAGE__::{CODE} entries. With filter_init, we don't know how that function was named, and looking it up, might be slow.
ok, I guess I'm still missing something because I still don't get it. but it doesn't matter - I'm sure it will clear up in time :)

of course, you could show up on IRC someday and explain it to me :)

[snip]


Nope, but first I want to add the add/remove functionality.
yeah, that was my thought. I started working on that but couldn't quite see all the pieces. here's what I have so far - it should compile cleanly and be good for a start, but it doesn't do anything (yet) due to the missing hooks.

--Geoff
Index: src/modules/perl/modperl_filter.c
===================================================================
RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/modperl_filter.c,v
retrieving revision 1.44
diff -u -r1.44 modperl_filter.c
--- src/modules/perl/modperl_filter.c   17 Jan 2003 03:08:31 -0000      1.44
+++ src/modules/perl/modperl_filter.c   22 Jan 2003 13:00:31 -0000
@@ -90,6 +90,20 @@
 
 #define MP_FILTER_POOL(f) f->r ? f->r->pool : f->c->pool
 
+
+modperl_filter_t *modperl_filter_init(ap_filter_t *f)
+{
+    apr_pool_t *p = MP_FILTER_POOL(f);
+    modperl_filter_t *filter = apr_pcalloc(p, sizeof(*filter));
+
+    filter->f = f;
+    filter->pool = p;
+   
+    MP_TRACE_f(MP_FUNC, "filter=0x%lx, mode=init\n");
+
+    return filter;
+}
+
 modperl_filter_t *modperl_filter_new(ap_filter_t *f,
                                      apr_bucket_brigade *bb,
                                      modperl_filter_mode_e mode)
@@ -554,6 +568,22 @@
         return APR_SUCCESS;
       case DECLINED:
         return ap_pass_brigade(f->next, bb);
+      default:
+        return status; /*XXX*/
+    }
+}
+
+apr_status_t modperl_init_filter_handler(ap_filter_t *f)
+{
+    modperl_filter_t *filter;
+    int status;
+
+    filter = modperl_filter_init(f);
+    status = modperl_run_filter(filter, 0, 0, 0);
+
+    switch (status) {
+      case OK:
+        return APR_SUCCESS;
       default:
         return status; /*XXX*/
     }
Index: src/modules/perl/modperl_filter.h
===================================================================
RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/modperl_filter.h,v
retrieving revision 1.17
diff -u -r1.17 modperl_filter.h
--- src/modules/perl/modperl_filter.h   17 Jan 2003 03:08:31 -0000      1.17
+++ src/modules/perl/modperl_filter.h   22 Jan 2003 13:00:31 -0000
@@ -9,6 +9,7 @@
 
 #define MP_FILTER_CONNECTION_HANDLER 0x01
 #define MP_FILTER_REQUEST_HANDLER    0x02
+#define MP_FILTER_INIT_HANDLER       0x03
 
 /* simple buffer api */
 MP_INLINE apr_status_t modperl_wbucket_pass(modperl_wbucket_t *b,
Index: xs/Apache/Filter/Apache__Filter.h
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/Apache/Filter/Apache__Filter.h,v
retrieving revision 1.22
diff -u -r1.22 Apache__Filter.h
--- xs/Apache/Filter/Apache__Filter.h   15 Jan 2003 06:11:08 -0000      1.22
+++ xs/Apache/Filter/Apache__Filter.h   22 Jan 2003 13:00:31 -0000
@@ -117,6 +117,12 @@
                 trace_attr();
                 continue;
             }
+          case 'I':
+            if (strEQ(pv, "InitHandler")) {
+                *attrs |= MP_FILTER_INIT_HANDLER;
+                trace_attr();
+                continue;
+            }
           default:
             XPUSHs_mortal_pv(attribute);
             XSRETURN(1);
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.98
diff -u -r1.98 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm  22 Jan 2003 06:12:43 -0000      1.98
+++ xs/tables/current/ModPerl/FunctionTable.pm  22 Jan 2003 13:00:31 -0000
@@ -1577,6 +1577,16 @@
   },
   {
     'return_type' => 'modperl_filter_t *',
+    'name' => 'modperl_filter_init',
+    'args' => [
+      {
+        'type' => 'ap_filter_t *',
+        'name' => 'f'
+      },
+    ]
+  },
+  {
+    'return_type' => 'modperl_filter_t *',
     'name' => 'modperl_filter_new',
     'args' => [
       {
@@ -3147,6 +3157,16 @@
         'type' => 'modperl_filter_t *',
         'name' => 'filter'
       }
+    ]
+  },
+  {
+    'return_type' => 'apr_status_t',
+    'name' => 'modperl_init_filter_handler',
+    'args' => [
+      {
+        'type' => 'ap_filter_t *',
+        'name' => 'f'
+      },
     ]
   },
   {

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to