httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1235019 - in /httpd/httpd/trunk: include/ap_mmn.h include/http_core.h include/httpd.h server/core_filters.c server/mpm/winnt/child.c
Date Mon, 23 Jan 2012 21:58:43 GMT
Author: sf
Date: Mon Jan 23 21:58:42 2012
New Revision: 1235019

URL: http://svn.apache.org/viewvc?rev=1235019&view=rev
Log:
Make the core input/output filter contexts private and provide accessor APIs
for mpm_winnt and mod_ftp.

This allows to add members to the context structs without breaking binary
compatibility.

Modified:
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/http_core.h
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/server/core_filters.c
    httpd/httpd/trunk/server/mpm/winnt/child.c

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1235019&r1=1235018&r2=1235019&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Mon Jan 23 21:58:42 2012
@@ -385,12 +385,16 @@
  * 20111203.1 (2.5.0-dev)  Add ap_list_provider_groups()
  * 20120109.0 (2.5.0-dev)  Changes sizeof(overrides_t) in core config.
  * 20120111.0 (2.5.0-dev)  Remove sb_type from global_score.
+ * 20120123.0 (2.5.0-dev)  Make core_output_filter_ctx_t and core_ctx_t
+ *                         private, add ap_create_core_ctx(),
+ *                         ap_core_ctx_get_bb(), move core_net rec definition
+ *                         to http_core.h
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20120111
+#define MODULE_MAGIC_NUMBER_MAJOR 20120123
 #endif
 #define MODULE_MAGIC_NUMBER_MINOR 0                   /* 0...n */
 

Modified: httpd/httpd/trunk/include/http_core.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_core.h?rev=1235019&r1=1235018&r2=1235019&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_core.h (original)
+++ httpd/httpd/trunk/include/http_core.h Mon Jan 23 21:58:42 2012
@@ -689,6 +689,40 @@ apr_status_t ap_core_output_filter(ap_fi
 AP_DECLARE(const char*) ap_get_server_protocol(server_rec* s);
 AP_DECLARE(void) ap_set_server_protocol(server_rec* s, const char* proto);
 
+typedef struct core_output_filter_ctx core_output_filter_ctx_t;
+typedef struct core_filter_ctx        core_ctx_t;
+
+typedef struct core_net_rec {
+    /** Connection to the client */
+    apr_socket_t *client_socket;
+
+    /** connection record */
+    conn_rec *c;
+
+    core_output_filter_ctx_t *out_ctx;
+    core_ctx_t *in_ctx;
+} core_net_rec;
+
+/**
+ * Allocate and fill the core_ctx_t for the core input filter, but don't
+ * create a bucket with the input socket.
+ * Normally this is done automatically when the core input filter is called
+ * for the first time, but MPMs or protocol modules that need to do special
+ * socket setup can call this function to do the initialization earlier.
+ * They must add the input socket bucket to the core input filter's bucket
+ * brigade, see ap_core_ctx_get_bb().
+ * @param c The conn_rec of the connection
+ * @return The core_ctx_t to be stored in core_net_rec->in_ctx
+ */
+AP_DECLARE(core_ctx_t *) ap_create_core_ctx(conn_rec *c);
+
+/**
+ * Accessor for the core input filter's bucket brigade
+ * @param c The core_ctx_t to get the brigade from
+ * @return The bucket brigade
+ */
+AP_DECLARE(apr_bucket_brigade *) ap_core_ctx_get_bb(core_ctx_t *ctx);
+
 /* ----------------------------------------------------------------------
  *
  * Runtime status/management

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1235019&r1=1235018&r2=1235019&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Mon Jan 23 21:58:42 2012
@@ -1270,30 +1270,6 @@ struct server_rec {
     void *context;
 };
 
-typedef struct core_output_filter_ctx {
-    apr_bucket_brigade *buffered_bb;
-    apr_bucket_brigade *tmp_flush_bb;
-    apr_pool_t *deferred_write_pool;
-    apr_size_t bytes_in;
-    apr_size_t bytes_written;
-} core_output_filter_ctx_t;
-
-typedef struct core_filter_ctx {
-    apr_bucket_brigade *b;
-    apr_bucket_brigade *tmpbb;
-} core_ctx_t;
-
-typedef struct core_net_rec {
-    /** Connection to the client */
-    apr_socket_t *client_socket;
-
-    /** connection record */
-    conn_rec *c;
-
-    core_output_filter_ctx_t *out_ctx;
-    core_ctx_t *in_ctx;
-} core_net_rec;
-
 /**
  * Get the context_document_root for a request. This is a generalization of
  * the document root, which is too limited in the presence of mappers like

Modified: httpd/httpd/trunk/server/core_filters.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core_filters.c?rev=1235019&r1=1235018&r2=1235019&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core_filters.c (original)
+++ httpd/httpd/trunk/server/core_filters.c Mon Jan 23 21:58:42 2012
@@ -78,6 +78,32 @@ do { \
 #undef APLOG_MODULE_INDEX
 #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
 
+typedef struct core_output_filter_ctx {
+    apr_bucket_brigade *buffered_bb;
+    apr_bucket_brigade *tmp_flush_bb;
+    apr_pool_t *deferred_write_pool;
+    apr_size_t bytes_written;
+} core_output_filter_ctx_t;
+
+typedef struct core_filter_ctx {
+    apr_bucket_brigade *b;
+    apr_bucket_brigade *tmpbb;
+} core_ctx_t;
+
+
+AP_DECLARE(core_ctx_t *) ap_create_core_ctx(conn_rec *c)
+{
+    core_ctx_t *ctx = apr_palloc(c->pool, sizeof(*ctx));
+    ctx->b = apr_brigade_create(c->pool, c->bucket_alloc);
+    ctx->tmpbb = apr_brigade_create(c->pool, c->bucket_alloc);
+    return ctx;
+}
+
+AP_DECLARE(apr_bucket_brigade *) ap_core_ctx_get_bb(core_ctx_t *ctx)
+{
+    return ctx->b;
+}
+
 int ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
                          ap_input_mode_t mode, apr_read_type_e block,
                          apr_off_t readbytes)
@@ -105,18 +131,10 @@ int ap_core_input_filter(ap_filter_t *f,
 
     if (!ctx)
     {
-        /*
-         * Note that this code is never executed on Windows because the winnt
-         * MPM does the setup of net->in_ctx.
-         * XXX: This should be fixed.
-         */
-        ctx = apr_pcalloc(f->c->pool, sizeof(*ctx));
-        ctx->b = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
-        ctx->tmpbb = apr_brigade_create(ctx->b->p, ctx->b->bucket_alloc);
+        net->in_ctx = ctx = ap_create_core_ctx(f->c);
         /* seed the brigade with the client socket. */
         e = apr_bucket_socket_create(net->client_socket, f->c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(ctx->b, e);
-        net->in_ctx = ctx;
     }
     else if (APR_BRIGADE_EMPTY(ctx->b)) {
         return APR_EOF;

Modified: httpd/httpd/trunk/server/mpm/winnt/child.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/child.c?rev=1235019&r1=1235018&r2=1235019&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/child.c (original)
+++ httpd/httpd/trunk/server/mpm/winnt/child.c Mon Jan 23 21:58:42 2012
@@ -812,7 +812,6 @@ static DWORD __stdcall worker_main(void 
         }
         else if (e)
         {
-            core_ctx_t *ctx;
             core_net_rec *net;
             ap_filter_t *filt;
 
@@ -820,24 +819,20 @@ static DWORD __stdcall worker_main(void 
             while ((strcmp(filt->frec->name, "core_in") != 0) && filt->next)
                 filt = filt->next;
             net = filt->ctx;
-            ctx = net->in_ctx;
 
-            if (net->in_ctx)
-                ctx = net->in_ctx;
-            else
+            if (net->in_ctx == NULL)
             {
-                ctx = apr_pcalloc(c->pool, sizeof(*ctx));
-                ctx->b = apr_brigade_create(c->pool, c->bucket_alloc);
-                ctx->tmpbb = apr_brigade_create(c->pool, c->bucket_alloc);
+                core_ctx_t *ctx = ap_create_core_ctx(c);
+                apr_bucket_brigade *bb = ap_core_ctx_get_bb(ctx);
 
                 /* seed the brigade with AcceptEx read heap bucket */
                 e = context->overlapped.Pointer;
-                APR_BRIGADE_INSERT_HEAD(ctx->b, e);
+                APR_BRIGADE_INSERT_HEAD(bb, e);
 
                 /* also seed the brigade with the client socket. */
                 e = apr_bucket_socket_create(net->client_socket,
                                              c->bucket_alloc);
-                APR_BRIGADE_INSERT_TAIL(ctx->b, e);
+                APR_BRIGADE_INSERT_TAIL(bb, e);
                 net->in_ctx = ctx;
             }
         }



Mime
View raw message