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-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cef28c4d8fb71ec2e17c2f179eada37c752788c9;p=thirdparty%2Fapache%2Fhttpd.git 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/modules/ssl@92209 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/ssl_engine_io.c b/ssl_engine_io.c index 70ab1657ce3..993fe1f6aee 100644 --- a/ssl_engine_io.c +++ b/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); } }