Commit cef28c4d authored by Doug MacEachern's avatar Doug MacEachern
Browse files

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
parent 1654c5dd
Loading
Loading
Loading
Loading
+34 −25
Changes for ssl_engine_io.c: 34 added lines, 25 removed lines.
Original line number Diff line number Diff line
@@ -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);
        }
    }