It's defined like this in http_core.h:

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;

Created in core_pre_connection() and passed to the core input/output
filters, the ->client_socket is the same as the conn_config_t's (which
the core filters could use instead), the ->c is unused, and the
->in/out_ctx fields are opaque and initialized by the core filters
themselves.

So could/should we remove this struct like the attached patch does
(trunk only, plus MMN major)?

Regards;
Yann.
Index: include/http_core.h
===================================================================
--- include/http_core.h	(revision 1884381)
+++ include/http_core.h	(working copy)
@@ -795,20 +795,6 @@ apr_status_t ap_core_output_filter(ap_filter_t *f,
 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;
-
 /**
  * Insert the network bucket into the core input filter's input brigade.
  * This hook is intended for MPMs or protocol modules that need to do special
Index: server/core.c
===================================================================
--- server/core.c	(revision 1884381)
+++ server/core.c	(working copy)
@@ -5508,15 +5508,14 @@ static conn_rec *core_create_conn(apr_pool_t *ptra
 
 static int core_pre_connection(conn_rec *c, void *csd)
 {
-    core_net_rec *net;
     conn_config_t *conn_config;
     apr_status_t rv;
 
+    /* only the master connection talks to the network */
     if (c->master) {
         return DONE;
     }
-    
-    net = apr_palloc(c->pool, sizeof(*net));
+
     /* The Nagle algorithm says that we should delay sending partial
      * packets in hopes of getting more data.  We don't want to do
      * this; we are not telnet.  There are bad interactions between
@@ -5546,22 +5545,13 @@ static int core_pre_connection(conn_rec *c, void *
                       "apr_socket_timeout_set");
     }
 
-    net->c = c;
-    net->in_ctx = NULL;
-    net->out_ctx = NULL;
-    net->client_socket = csd;
-
-    conn_config = apr_palloc(c->pool, sizeof(conn_config));
+    conn_config = apr_pcalloc(c->pool, sizeof(*conn_config));
     conn_config->socket = csd;
-    ap_set_core_module_config(net->c->conn_config, conn_config);
+    ap_set_core_module_config(c->conn_config, conn_config);
 
-    /* only the master connection talks to the network */
-    if (c->master == NULL) {
-        ap_add_input_filter_handle(ap_core_input_filter_handle, net, NULL,
-                                   net->c);
-        ap_add_output_filter_handle(ap_core_output_filter_handle, net, NULL,
-                                    net->c);
-    }
+    ap_add_input_filter_handle(ap_core_input_filter_handle, NULL, NULL, c);
+    ap_add_output_filter_handle(ap_core_output_filter_handle, NULL, NULL, c);
+
     return DONE;
 }
 
Index: server/core_filters.c
===================================================================
--- server/core_filters.c	(revision 1884381)
+++ server/core_filters.c	(working copy)
@@ -78,17 +78,17 @@ do { \
 #undef APLOG_MODULE_INDEX
 #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
 
-struct core_output_filter_ctx {
+typedef struct {
     apr_bucket_brigade *empty_bb;
     apr_size_t bytes_written;
     struct iovec *vec;
     apr_size_t nvec;
-};
+} core_output_ctx_t;
 
-struct core_filter_ctx {
+typedef struct {
     apr_bucket_brigade *bb;
     apr_bucket_brigade *tmpbb;
-};
+} core_input_ctx_t;
 
 
 apr_status_t ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b,
@@ -95,9 +95,10 @@ apr_status_t ap_core_input_filter(ap_filter_t *f,
                                   ap_input_mode_t mode, apr_read_type_e block,
                                   apr_off_t readbytes)
 {
+    conn_rec *c = f->c;
+    core_input_ctx_t *ctx = f->ctx;
+    conn_config_t *conf = ap_get_core_module_config(c->conn_config);
     apr_status_t rv = APR_SUCCESS;
-    core_net_rec *net = f->ctx;
-    core_ctx_t *ctx = net->in_ctx;
     const char *str;
     apr_size_t len;
 
@@ -117,11 +118,11 @@ apr_status_t ap_core_input_filter(ap_filter_t *f,
 
     if (!ctx)
     {
-        net->in_ctx = ctx = apr_palloc(f->c->pool, sizeof(*ctx));
-        ctx->bb = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
-        ctx->tmpbb = apr_brigade_create(f->c->pool, f->c->bucket_alloc);
+        f->ctx = ctx = apr_palloc(c->pool, sizeof(*ctx));
+        ctx->bb = apr_brigade_create(c->pool, c->bucket_alloc);
+        ctx->tmpbb = apr_brigade_create(c->pool, c->bucket_alloc);
         /* seed the brigade with the client socket. */
-        rv = ap_run_insert_network_bucket(f->c, ctx->bb, net->client_socket);
+        rv = ap_run_insert_network_bucket(c, ctx->bb, conf->socket);
         if (rv != APR_SUCCESS)
             return rv;
     }
@@ -163,7 +164,7 @@ apr_status_t ap_core_input_filter(ap_filter_t *f,
      * this mode.  Determine whether anyone actually uses this or not. */
     if (mode == AP_MODE_EATCRLF) {
         apr_bucket *e;
-        const char *c;
+        const char *ch;
 
         /* The purpose of this loop is to ignore any CRLF (or LF) at the end
          * of a request.  Many browsers send extra lines at the end of POST
@@ -186,12 +187,12 @@ apr_status_t ap_core_input_filter(ap_filter_t *f,
                 goto cleanup;
             }
 
-            c = str;
-            while (c < str + len) {
-                if (*c == APR_ASCII_LF)
-                    c++;
-                else if (*c == APR_ASCII_CR && *(c + 1) == APR_ASCII_LF)
-                    c += 2;
+            ch = str;
+            while (ch < str + len) {
+                if (*ch == APR_ASCII_LF)
+                    ch++;
+                else if (*ch == APR_ASCII_CR && *(ch + 1) == APR_ASCII_LF)
+                    ch += 2;
                 else
                     goto cleanup;
             }
@@ -227,7 +228,7 @@ apr_status_t ap_core_input_filter(ap_filter_t *f,
          * so tack on an EOS too. */
         /* We have read until the brigade was empty, so we know that we
          * must be EOS. */
-        e = apr_bucket_eos_create(f->c->bucket_alloc);
+        e = apr_bucket_eos_create(c->bucket_alloc);
         APR_BRIGADE_INSERT_TAIL(b, e);
 
         rv = APR_SUCCESS;
@@ -262,7 +263,7 @@ apr_status_t ap_core_input_filter(ap_filter_t *f,
             apr_bucket_delete(e);
 
             if (mode == AP_MODE_READBYTES) {
-                e = apr_bucket_eos_create(f->c->bucket_alloc);
+                e = apr_bucket_eos_create(c->bucket_alloc);
                 APR_BRIGADE_INSERT_TAIL(b, e);
             }
             goto cleanup;
@@ -340,12 +341,12 @@ cleanup:
 
 static apr_status_t send_brigade_nonblocking(apr_socket_t *s,
                                              apr_bucket_brigade *bb,
-                                             core_output_filter_ctx_t *ctx,
+                                             core_output_ctx_t *ctx,
                                              conn_rec *c);
 
 static apr_status_t writev_nonblocking(apr_socket_t *s,
                                        apr_bucket_brigade *bb,
-                                       core_output_filter_ctx_t *ctx,
+                                       core_output_ctx_t *ctx,
                                        apr_size_t bytes_to_write,
                                        apr_size_t nvec,
                                        conn_rec *c);
@@ -353,7 +354,7 @@ static apr_status_t writev_nonblocking(apr_socket_
 #if APR_HAS_SENDFILE
 static apr_status_t sendfile_nonblocking(apr_socket_t *s,
                                          apr_bucket *bucket,
-                                         core_output_filter_ctx_t *ctx,
+                                         core_output_ctx_t *ctx,
                                          conn_rec *c);
 #endif
 
@@ -365,9 +366,9 @@ extern APR_OPTIONAL_FN_TYPE(ap_logio_add_bytes_out
 apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
 {
     conn_rec *c = f->c;
-    core_net_rec *net = f->ctx;
-    apr_socket_t *sock = net->client_socket;
-    core_output_filter_ctx_t *ctx = net->out_ctx;
+    core_output_ctx_t *ctx = f->ctx;
+    conn_config_t *conf = ap_get_core_module_config(c->conn_config);
+    apr_socket_t *sock = conf->socket;
     apr_interval_time_t sock_timeout = 0;
     apr_status_t rv;
 
@@ -378,8 +379,7 @@ apr_status_t ap_core_output_filter(ap_filter_t *f,
     }
 
     if (ctx == NULL) {
-        ctx = apr_pcalloc(c->pool, sizeof(*ctx));
-        net->out_ctx = (core_output_filter_ctx_t *)ctx;
+        f->ctx = ctx = apr_pcalloc(c->pool, sizeof(*ctx));
     }
 
     /* remain compatible with legacy MPMs that passed NULL to this filter */
@@ -490,11 +490,11 @@ static APR_INLINE int can_sendfile_bucket(apr_buck
 
 static apr_status_t send_brigade_nonblocking(apr_socket_t *s,
                                              apr_bucket_brigade *bb,
-                                             core_output_filter_ctx_t *ctx,
+                                             core_output_ctx_t *ctx,
                                              conn_rec *c)
 {
     apr_status_t rv = APR_SUCCESS;
-    core_server_config *conf =
+    core_server_config *sconf =
         ap_get_core_module_config(c->base_server->module_config);
     apr_size_t nvec = 0, nbytes = 0;
     apr_bucket *bucket, *next;
@@ -610,7 +610,7 @@ static apr_status_t send_brigade_nonblocking(apr_s
          * we are at the end of the brigade, the write will happen outside
          * the loop anyway).
          */
-        if (nbytes > conf->flush_max_threshold
+        if (nbytes > sconf->flush_max_threshold
                 && next != APR_BRIGADE_SENTINEL(bb)
                 && !is_in_memory_bucket(next)) {
             (void)apr_socket_opt_set(s, APR_TCP_NOPUSH, 1);
@@ -633,7 +633,7 @@ cleanup:
 
 static apr_status_t writev_nonblocking(apr_socket_t *s,
                                        apr_bucket_brigade *bb,
-                                       core_output_filter_ctx_t *ctx,
+                                       core_output_ctx_t *ctx,
                                        apr_size_t bytes_to_write,
                                        apr_size_t nvec,
                                        conn_rec *c)
@@ -693,7 +693,7 @@ static apr_status_t writev_nonblocking(apr_socket_
 
 static apr_status_t sendfile_nonblocking(apr_socket_t *s,
                                          apr_bucket *bucket,
-                                         core_output_filter_ctx_t *ctx,
+                                         core_output_ctx_t *ctx,
                                          conn_rec *c)
 {
     apr_status_t rv;

Reply via email to