]> granicus.if.org Git - apache/commitdiff
destroy the brigade when we are done with it, rather than remove
authorDoug MacEachern <dougm@apache.org>
Wed, 22 Aug 2001 15:30:37 +0000 (15:30 +0000)
committerDoug MacEachern <dougm@apache.org>
Wed, 22 Aug 2001 15:30:37 +0000 (15:30 +0000)
one bucket at a time.  prevents a problem when downloading large files.
also change ssl_io_filter_Output to apache style
and change some variable names that should make the code easier to
read/understand, e.g. pbbIn -> bb, pbktIn -> bucket
PR:
Obtained from:
Submitted by:
Reviewed by:

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

modules/ssl/ssl_engine_io.c

index 75b7467b5e773cfc93909080c641ff7e9bd6eabb..7fb4f8b896b817e9e3edc6da91d0894044047f03 100644 (file)
@@ -326,41 +326,38 @@ static apr_status_t churn (SSLFilterRec *pRec,
     return churn_output(pRec);
 }
 
-static apr_status_t ssl_io_filter_Output(ap_filter_t *f,apr_bucket_brigade *pbbIn)
+static apr_status_t ssl_io_filter_Output(ap_filter_t *f,
+                                         apr_bucket_brigade *bb)
 {
-    SSLFilterRec *pRec=f->ctx;
-    apr_bucket *pbktIn;
-
-    APR_BRIGADE_FOREACH(pbktIn,pbbIn) {
-       const char *data;
-       apr_size_t len, n;
-       apr_status_t ret;
-
-        APR_BUCKET_REMOVE(pbktIn);
-
-       if(APR_BUCKET_IS_EOS(pbktIn)) {
-           if ((ret = churn_output(pRec)) != APR_SUCCESS)
-            {
-                ap_log_error(
-                    APLOG_MARK,APLOG_ERR,ret,NULL, "Error in churn_output");
-               return ret;
+    SSLFilterRec *ctx = f->ctx;
+    apr_bucket *bucket;
+    apr_status_t ret = APR_SUCCESS;
+
+    APR_BRIGADE_FOREACH(bucket, bb) {
+        const char *data;
+        apr_size_t len, n;
+
+        if (APR_BUCKET_IS_EOS(bucket)) {
+            if ((ret = churn_output(ctx)) != APR_SUCCESS) {
+                ap_log_error(APLOG_MARK, APLOG_ERR, ret, NULL,
+                             "Error in churn_output");
             }
-           break;
-       }
+            break;
+        }
 
-       if (!APR_BUCKET_IS_FLUSH(pbktIn)) {
+        if (!APR_BUCKET_IS_FLUSH(bucket)) {
             /* read filter */
-            apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
+            apr_bucket_read(bucket, &data, &len, APR_BLOCK_READ);
 
             /* write SSL */
-            n = ssl_io_hook_write(pRec->pssl, (unsigned char *)data, len);
+            n = ssl_io_hook_write(ctx->pssl, (unsigned char *)data, len);
 
             if (n != len) {
-                conn_rec *c = (conn_rec *)SSL_get_app_data(pRec->pssl);
+                conn_rec *c = f->c;
                 char *reason = "reason unknown";
 
                 /* XXX: probably a better way to determine this */
-                if (SSL_total_renegotiations(pRec->pssl)) {
+                if (SSL_total_renegotiations(ctx->pssl)) {
                     reason = "likely due to failed renegotiation";
                 }
 
@@ -368,19 +365,22 @@ static apr_status_t ssl_io_filter_Output(ap_filter_t *f,apr_bucket_brigade *pbbI
                         "failed to write %d of %d bytes (%s)",
                         n > 0 ? len - n : len, len, reason);
 
-                return APR_EINVAL;
+                ret = APR_EINVAL;
+                break;
             }
         }
         /* else fallthrough to flush the current wbio
          * likely triggered by renegotiation in ssl_hook_Access
          */
 
-       /* churn the state machine */
-       ret=churn_output(pRec);
-       if(ret != APR_SUCCESS)
-           return ret;
+        /* churn the state machine */
+        if ((ret = churn_output(ctx)) != APR_SUCCESS) {
+            break;
+        }
     }
-    return APR_SUCCESS;
+
+    apr_brigade_destroy(bb);
+    return ret;
 }
 
 static apr_status_t ssl_io_filter_Input(ap_filter_t *f,apr_bucket_brigade *pbbOut,