From: Doug MacEachern Date: Wed, 28 Nov 2001 03:15:41 +0000 (+0000) Subject: moving chunk of logic that deals with writing ssl data from X-Git-Tag: 2.0.30~368 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6497301dc59366376639dbfa4dcd1a5f7ceacfc;p=apache moving chunk of logic that deals with writing ssl data from ssl_io_filter_Output() to a new ssl_filter_write() function. this will make it easier to optimize how we deal with file buckets than cannot be mmaped. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92209 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/ssl/ssl_engine_io.c b/modules/ssl/ssl_engine_io.c index 70ab1657ce..993fe1f6ae 100644 --- a/modules/ssl/ssl_engine_io.c +++ b/modules/ssl/ssl_engine_io.c @@ -363,6 +363,36 @@ static apr_status_t churn_output(SSLFilterRec *ctx) return BIO_bucket_flush(ctx->pbioWrite); } +static apr_status_t ssl_filter_write(ap_filter_t *f, + const char *data, + apr_size_t len) +{ + SSLFilterRec *ctx = f->ctx; + apr_size_t n; + + /* write SSL */ + n = ssl_io_hook_write(ctx->pssl, (unsigned char *)data, len); + + if (n != len) { + conn_rec *c = f->c; + char *reason = "reason unknown"; + + /* XXX: probably a better way to determine this */ + if (SSL_total_renegotiations(ctx->pssl)) { + reason = "likely due to failed renegotiation"; + } + + ssl_log(c->base_server, SSL_LOG_ERROR, + "failed to write %d of %d bytes (%s)", + n > 0 ? len - n : len, len, reason); + + return APR_EINVAL; + } + + /* churn the state machine */ + return churn_output(ctx); +} + #define bio_is_renegotiating(bio) \ (((int)BIO_get_callback_arg(bio)) == SSL_ST_RENEGOTIATE) #define HTTP_ON_HTTPS_PORT "GET /mod_ssl:error:HTTP-request HTTP/1.0\r\n" @@ -565,7 +595,7 @@ static apr_status_t ssl_io_filter_Output(ap_filter_t *f, while (!APR_BRIGADE_EMPTY(bb)) { const char *data; - apr_size_t len, n; + apr_size_t len; bucket = APR_BRIGADE_FIRST(bb); @@ -596,33 +626,12 @@ static apr_status_t ssl_io_filter_Output(ap_filter_t *f, else { /* read filter */ apr_bucket_read(bucket, &data, &len, APR_BLOCK_READ); + ret = ssl_filter_write(f, data, len); + apr_bucket_delete(bucket); - /* write SSL */ - n = ssl_io_hook_write(ctx->pssl, (unsigned char *)data, len); - - if (n != len) { - conn_rec *c = f->c; - char *reason = "reason unknown"; - - /* XXX: probably a better way to determine this */ - if (SSL_total_renegotiations(ctx->pssl)) { - reason = "likely due to failed renegotiation"; - } - - ssl_log(c->base_server, SSL_LOG_ERROR, - "failed to write %d of %d bytes (%s)", - n > 0 ? len - n : len, len, reason); - - ret = APR_EINVAL; - break; - } - - /* churn the state machine */ - if ((ret = churn_output(ctx)) != APR_SUCCESS) { + if (ret != APR_SUCCESS) { break; } - - apr_bucket_delete(bucket); } }