]> granicus.if.org Git - apache/commitdiff
Moved split_and_pass_pretag_buckets back to being a
authorPaul J. Reder <rederpj@apache.org>
Mon, 27 Aug 2001 20:25:42 +0000 (20:25 +0000)
committerPaul J. Reder <rederpj@apache.org>
Mon, 27 Aug 2001 20:25:42 +0000 (20:25 +0000)
macro at Ryans's request. Removed the return from it
by setting and returning a return code instead. Updated
the code to check the return code from teh macro and
do the right thing.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@90735 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/filters/mod_include.c
modules/filters/mod_include.h
modules/generators/mod_cgi.c
modules/generators/mod_cgid.c

diff --git a/CHANGES b/CHANGES
index 3951d8221e5cc13aadccf73f098bc4f08815c55c..d6a0ca63cbd04e320cebcee479aa17232d06c615 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,9 @@
 Changes with Apache 2.0.25-dev
+  *) Moved split_and_pass_pretag_buckets back to being a
+     macro at Ryans's request. Removed the return from it
+     by setting and returning a return code instead. Updated
+     the code to check the return code from teh macro and
+     do the right thing. [Paul J. Reder]
 
   *) Fix a segfault when a numeric value was received for Host:.
      [Jeff Trawick]
index f89decdb9067b980da0229bf88ba1698e7c5bf54..b6c0ed1ad1608e008b3bf0303ef0991da8401b03 100644 (file)
@@ -98,30 +98,6 @@ static APR_OPTIONAL_FN_TYPE(ap_register_include_handler) *ssi_pfn_register;
 
 #define BYTE_COUNT_THRESHOLD AP_MIN_BYTES_TO_WRITE
 
-/* This function is used to split the brigade at the beginning of
- *   the tag and forward the pretag buckets before any substitution
- *   work is performed on the tag. This maintains proper ordering.
- */
-static int split_and_pass_pretag_buckets(apr_bucket_brigade **brgd, 
-                                         include_ctx_t *cntxt, 
-                                         ap_filter_t *next)
-{
-    apr_bucket_brigade *tag_plus;
-    int rv;
-
-    if ((APR_BRIGADE_EMPTY(cntxt->ssi_tag_brigade)) &&
-        (cntxt->head_start_bucket != NULL)) {
-        tag_plus = apr_brigade_split(*brgd, cntxt->head_start_bucket);
-        rv = ap_pass_brigade(next, *brgd);
-        cntxt->bytes_parsed = 0;
-        *brgd = tag_plus;
-        if (rv != APR_SUCCESS) {
-            return rv;
-        }
-    }
-    return APR_SUCCESS;
-}
-
 /* ------------------------ Environment function -------------------------- */
 
 /* XXX: could use ap_table_overlap here */
@@ -881,10 +857,11 @@ static int handle_include(include_ctx_t *ctx, apr_bucket_brigade **bb, request_r
 
                 if (!error_fmt) {
                     int rv;
+                    apr_status_t rc = APR_SUCCESS;
 
-                    rv = split_and_pass_pretag_buckets(bb, ctx, f->next);
-                    if (rv != APR_SUCCESS) {
-                        return rv;
+                    SPLIT_AND_PASS_PRETAG_BUCKETS(*bb, ctx, f->next, rc);
+                    if (rc != APR_SUCCESS) {
+                        return rc;
                     }
                     
                     if ((rv = ap_run_sub_req(rr))) {
@@ -2369,7 +2346,7 @@ static apr_status_t send_parsed_content(apr_bucket_brigade **bb,
     apr_bucket *dptr = APR_BRIGADE_FIRST(*bb);
     apr_bucket *tmp_dptr;
     apr_bucket_brigade *tag_and_after;
-    apr_status_t rv;
+    apr_status_t rv = APR_SUCCESS;
 
     if (r->args) {              /* add QUERY stuff to env cause it ain't yet */
         char *arg_copy = apr_pstrdup(r->pool, r->args);
@@ -2462,7 +2439,7 @@ static apr_status_t send_parsed_content(apr_bucket_brigade **bb,
                     *bb = tag_and_after;
                 }
                 else if (ctx->bytes_parsed >= BYTE_COUNT_THRESHOLD) {
-                    rv = split_and_pass_pretag_buckets(bb, ctx, f->next);
+                    SPLIT_AND_PASS_PRETAG_BUCKETS(*bb, ctx, f->next, rv);
                     if (rv != APR_SUCCESS) {
                         return rv;
                     }
index ce7ee58398ffc69e66b7de34b0b8c0cd1ab5224d..4837182545c1af739ec8b4fd39fa428d09112fe5 100644 (file)
@@ -183,6 +183,22 @@ typedef struct include_filter_ctx {
     }                                                             \
 }
 
+/* Make sure to check the return code rc. If it is anything other
+ *   than APR_SUCCESS, then you should return this value up the
+ *   call chain.
+ */
+#define SPLIT_AND_PASS_PRETAG_BUCKETS(brgd, cntxt, next, rc)      \
+if ((APR_BRIGADE_EMPTY(cntxt->ssi_tag_brigade)) &&                \
+    (cntxt->head_start_bucket != NULL)) {                         \
+    apr_bucket_brigade *tag_plus;                                 \
+                                                                  \
+    tag_plus = apr_brigade_split(brgd, cntxt->head_start_bucket); \
+    rc = ap_pass_brigade(next, brgd);                             \
+    cntxt->bytes_parsed = 0;                                      \
+    brgd = tag_plus;                                              \
+}
+
+
 typedef int (include_handler_fn_t)(include_ctx_t *ctx, apr_bucket_brigade **bb,
                        request_rec *r, ap_filter_t *f, apr_bucket *head_ptr, 
                        apr_bucket **inserted_head);
index df918228e38e87daa1c20c13f76636b21b5624fc..a25778dd779b42a852fb4b0cca7c020101b43091 100644 (file)
@@ -137,30 +137,6 @@ typedef struct {
     int bufbytes;
 } cgi_server_conf;
 
-/* This function is used to split the brigade at the beginning of
- *   the tag and forward the pretag buckets before any substitution
- *   work is performed on the tag. This maintains proper ordering.
- */
-static int split_and_pass_pretag_buckets(apr_bucket_brigade **brgd, 
-                                         include_ctx_t *cntxt, 
-                                         ap_filter_t *next)
-{
-    apr_bucket_brigade *tag_plus;
-    int rv;
-
-    if ((APR_BRIGADE_EMPTY(cntxt->ssi_tag_brigade)) &&
-        (cntxt->head_start_bucket != NULL)) {
-        tag_plus = apr_brigade_split(*brgd, cntxt->head_start_bucket);
-        rv = ap_pass_brigade(next, *brgd);
-        cntxt->bytes_parsed = 0;
-        *brgd = tag_plus;
-        if (rv != APR_SUCCESS) {
-            return rv;
-        }
-    }
-    return APR_SUCCESS;
-}
-
 static void *create_cgi_config(apr_pool_t *p, server_rec *s)
 {
     cgi_server_conf *c =
@@ -466,7 +442,7 @@ static apr_status_t run_cgi_child(apr_file_t **script_out,
     else {
         procnew = apr_pcalloc(p, sizeof(*procnew));
         if (e_info->prog_type == RUN_AS_SSI) {
-            rc = split_and_pass_pretag_buckets(e_info->bb, e_info->ctx, e_info->next);
+            SPLIT_AND_PASS_PRETAG_BUCKETS(*(e_info->bb), e_info->ctx, e_info->next, rc);
             if (rc != APR_SUCCESS) {
                 return rc;
             }
@@ -925,7 +901,6 @@ static int handle_exec(include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec
     char *tag     = NULL;
     char *tag_val = NULL;
     char *file = r->filename;
-    int retval;
     apr_bucket  *tmp_buck;
     char parsed_string[MAX_STRING_LEN];
 
@@ -957,8 +932,10 @@ static int handle_exec(include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec
                     }
                 }
                 else if (!strcmp(tag, "cgi")) {
+                    apr_status_t retval = APR_SUCCESS;
+
                     cgi_pfn_ps(r, tag_val, parsed_string, sizeof(parsed_string), 0);
-                    retval = split_and_pass_pretag_buckets(bb, ctx, f->next);
+                    SPLIT_AND_PASS_PRETAG_BUCKETS(*bb, ctx, f->next, retval);
                     if (retval != APR_SUCCESS) {
                         return retval;
                     }
index 4eb876f26491753e235da74466a056d988020539..1ecaa44e02b7b8984c935b759968cb860e8736a7 100644 (file)
@@ -169,30 +169,6 @@ typedef struct {
     int bufbytes; 
 } cgid_server_conf; 
 
-/* This function is used to split the brigade at the beginning of
- *   the tag and forward the pretag buckets before any substitution
- *   work is performed on the tag. This maintains proper ordering.
- */
-static int split_and_pass_pretag_buckets(apr_bucket_brigade **brgd, 
-                                         include_ctx_t *cntxt, 
-                                         ap_filter_t *next)
-{
-    apr_bucket_brigade *tag_plus;
-    int rv;
-
-    if ((APR_BRIGADE_EMPTY(cntxt->ssi_tag_brigade)) &&
-        (cntxt->head_start_bucket != NULL)) {
-        tag_plus = apr_brigade_split(*brgd, cntxt->head_start_bucket);
-        rv = ap_pass_brigade(next, *brgd);
-        cntxt->bytes_parsed = 0;
-        *brgd = tag_plus;
-        if (rv != APR_SUCCESS) {
-            return rv;
-        }
-    }
-    return APR_SUCCESS;
-}
-
 /* If a request includes query info in the URL (stuff after "?"), and
  * the query info does not contain "=" (indicative of a FORM submission),
  * then this routine is called to create the argument list to be passed
@@ -1175,7 +1151,8 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb, char *comman
     char **env; 
     const char *location; 
     int sd;
-    int retval; 
+    apr_status_t rc = APR_SUCCESS; 
+    int retval;
     apr_bucket_brigade *bcgi;
     apr_bucket *b;
     struct sockaddr_un unix_addr;
@@ -1200,9 +1177,9 @@ static int include_cmd(include_ctx_t *ctx, apr_bucket_brigade **bb, char *comman
                                    "unable to connect to cgi daemon");
     } 
 
-    retval = split_and_pass_pretag_buckets(bb, ctx, f->next);
-    if (retval != APR_SUCCESS) {
-        return retval;
+    SPLIT_AND_PASS_PRETAG_BUCKETS(*bb, ctx, f->next, rc);
+    if (rc != APR_SUCCESS) {
+        return rc;
     }
 
     send_req(sd, r, command, env, SSI_REQ); 
@@ -1264,7 +1241,6 @@ static int handle_exec(include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec
     char *file = r->filename;
     apr_bucket  *tmp_buck;
     char parsed_string[MAX_STRING_LEN];
-    int retval;
 
     *inserted_head = NULL;
     if (ctx->flags & FLAG_PRINTING) {
@@ -1295,8 +1271,10 @@ static int handle_exec(include_ctx_t *ctx, apr_bucket_brigade **bb, request_rec
                     /* just in case some stooge changed directories */
                 }
                 else if (!strcmp(tag, "cgi")) {
+                    apr_status_t retval = APR_SUCCESS;
+
                     cgid_pfn_ps(r, tag_val, parsed_string, sizeof(parsed_string), 0);
-                    retval = split_and_pass_pretag_buckets(bb, ctx, f->next);
+                    SPLIT_AND_PASS_PRETAG_BUCKETS(*bb, ctx, f->next, retval);
                     if (retval != APR_SUCCESS) {
                         return retval;
                     }