Commit 3d8d13e1 authored by Stefan Eissing's avatar Stefan Eissing
Browse files

Merge of r1765328,1766424,1766691,1766851 from trunk:

mod_http2: v1.7.7, connection shutdown revisited, AP_DEBUG_ASSERT transformed to real asserts


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1766856 13f79535-47bb-0310-9956-ffa450edef68
parent 6d57c7e3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,13 @@

Changes with Apache 2.4.24

  *) mod_http2: connection shutdown revisited: corrected edge cases on
     shutting down ongoing streams, changed log warnings to be less noisy
     when waiting on long running tasks. [Stefan Eissing]

  *) mod_http2: changed all AP_DEBUG_ASSERT to ap_assert to have them 
     available also in normal deployments. [Stefan Eissing]

  *) mod_http2/mod_proxy_http2: 100-continue handling now properly implemented
     up to the backend. Reused HTTP/2 proxy connections with more than a second
     not used will block request bodies until a PING answer is received.
+40 −25
Original line number Diff line number Diff line
@@ -377,7 +377,7 @@ static void h2_beam_emitted(h2_bucket_beam *beam, h2_beam_proxy *proxy)
                              APLOGNO(03384) "h2_beam(%d-%s): emitted bucket not "
                              "in hold, n=%d", beam->id, beam->tag, 
                              (int)proxy->n);
                AP_DEBUG_ASSERT(!proxy->bred);
                ap_assert(!proxy->bred);
            }
        }
        /* notify anyone waiting on space to become available */
@@ -413,6 +413,32 @@ static apr_status_t beam_close(h2_bucket_beam *beam)
}

static void beam_set_red_pool(h2_bucket_beam *beam, apr_pool_t *pool);
static void beam_set_green_pool(h2_bucket_beam *beam, apr_pool_t *pool);

static apr_status_t beam_green_cleanup(void *data)
{
    h2_bucket_beam *beam = data;

    if (beam->green) {
        apr_brigade_destroy(beam->green);
        beam->green = NULL;
    }
    beam->green_pool = NULL;
    return APR_SUCCESS;
}

static void beam_set_green_pool(h2_bucket_beam *beam, apr_pool_t *pool) 
{
    if (beam->green_pool != pool) {
        if (beam->green_pool) {
            apr_pool_cleanup_kill(beam->green_pool, beam, beam_green_cleanup);
        }
        beam->green_pool = pool;
        if (beam->green_pool) {
            apr_pool_pre_cleanup_register(beam->green_pool, beam, beam_green_cleanup);
        }
    }
}

static apr_status_t beam_red_cleanup(void *data)
{
@@ -429,8 +455,7 @@ static apr_status_t beam_red_cleanup(void *data)
    }
    h2_blist_cleanup(&beam->purge);
    h2_blist_cleanup(&beam->hold);
    beam_set_red_pool(beam, NULL); 
    
    beam->red_pool = NULL;
    return APR_SUCCESS;
}

@@ -453,10 +478,16 @@ static apr_status_t beam_cleanup(void *data)
    apr_status_t status;
    
    beam_close(beam);
    if (beam->green_pool) {
        apr_pool_cleanup_kill(beam->green_pool, beam, beam_green_cleanup);
        status = beam_green_cleanup(beam);
    }

    if (beam->red_pool) {
        apr_pool_cleanup_kill(beam->red_pool, beam, beam_red_cleanup);
        status = beam_red_cleanup(beam);
    }
    return APR_SUCCESS;
    return status;
}

apr_status_t h2_beam_destroy(h2_bucket_beam *beam)
@@ -582,27 +613,15 @@ apr_status_t h2_beam_close(h2_bucket_beam *beam)
    return beam->aborted? APR_ECONNABORTED : APR_SUCCESS;
}

apr_status_t h2_beam_shutdown(h2_bucket_beam *beam, apr_read_type_e block,
                              int clear_buffers)
apr_status_t h2_beam_wait_empty(h2_bucket_beam *beam, apr_read_type_e block)
{
    apr_status_t status;
    h2_beam_lock bl;
    
    if ((status = enter_yellow(beam, &bl)) == APR_SUCCESS) {
        if (clear_buffers) {
            r_purge_reds(beam);
            h2_blist_cleanup(&beam->red);
            if (!bl.mutex && beam->green) {
                /* not protected, may process green in red call */
                apr_brigade_destroy(beam->green);
                beam->green = NULL;
            }
        }
        beam_close(beam);
        
        while (status == APR_SUCCESS
               && (!H2_BPROXY_LIST_EMPTY(&beam->proxies)
                   || (beam->green && !APR_BRIGADE_EMPTY(beam->green)))) {
               && !H2_BLIST_EMPTY(&beam->red)
               && !H2_BPROXY_LIST_EMPTY(&beam->proxies)) {
            if (block == APR_NONBLOCK_READ || !bl.mutex) {
                status = APR_EAGAIN;
                break;
@@ -810,6 +829,7 @@ transfer:
        }

        /* transfer enough buckets from our green brigade, if we have one */
        beam_set_green_pool(beam, bb->p);
        while (beam->green
               && !APR_BRIGADE_EMPTY(beam->green)
               && (readbytes <= 0 || remain >= 0)) {
@@ -1068,11 +1088,6 @@ int h2_beam_holds_proxies(h2_bucket_beam *beam)
    return has_proxies;
}

int h2_beam_closed(h2_bucket_beam *beam)
{
    return beam->closed;
}

int h2_beam_was_received(h2_bucket_beam *beam)
{
    int happend = 0;
+3 −10
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ apr_size_t h2_util_bl_print(char *buffer, apr_size_t bmax,
 * Care needs to be taken when terminating the beam. The beam registers at
 * the pool it was created with and will cleanup after itself. However, if
 * received buckets do still exist, already freed memory might be accessed.
 * The beam does a AP_DEBUG_ASSERT on this condition.
 * The beam does a assertion on this condition.
 * 
 * The proper way of shutting down a beam is to first make sure there are no
 * more green buckets out there, then cleanup the beam to purge eventually
@@ -179,6 +179,7 @@ struct h2_bucket_beam {
    apr_bucket_brigade *green;
    h2_bproxy_list proxies;
    apr_pool_t *red_pool;
    apr_pool_t *green_pool;
    
    apr_size_t max_buf_size;
    apr_interval_time_t timeout;
@@ -259,13 +260,6 @@ apr_status_t h2_beam_receive(h2_bucket_beam *beam,
                             apr_read_type_e block,
                             apr_off_t readbytes);

/**
 * Determine if beam is closed. May still contain buffered data. 
 * 
 * Call from red or green side.
 */
int h2_beam_closed(h2_bucket_beam *beam);

/**
 * Determine if beam is empty. 
 * 
@@ -305,8 +299,7 @@ apr_status_t h2_beam_close(h2_bucket_beam *beam);
 *
 * Call from the red side only.
 */
apr_status_t h2_beam_shutdown(h2_bucket_beam *beam, apr_read_type_e block,
                              int clear_buffers);
apr_status_t h2_beam_wait_empty(h2_bucket_beam *beam, apr_read_type_e block);

void h2_beam_mutex_set(h2_bucket_beam *beam, 
                       h2_beam_mutex_enter m_enter,
+1 −1
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ const h2_config *h2_config_sget(server_rec *s)
{
    h2_config *cfg = (h2_config *)ap_get_module_config(s->module_config, 
                                                       &http2_module);
    AP_DEBUG_ASSERT(cfg);
    ap_assert(cfg);
    return cfg;
}

+1 −1
Original line number Diff line number Diff line
@@ -248,7 +248,7 @@ conn_rec *h2_slave_create(conn_rec *master, int slave_id,
    conn_rec *c;
    void *cfg;
    
    AP_DEBUG_ASSERT(master);
    ap_assert(master);
    ap_log_cerror(APLOG_MARK, APLOG_TRACE3, 0, master,
                  "h2_conn(%ld): create slave", master->id);
    
Loading