Beispiel #1
0
h2_stream *h2_mplx_open_io(h2_mplx *m, int stream_id)
{
    h2_stream *stream = NULL;
    apr_status_t status; 
    h2_io *io;

    if (m->aborted) {
        return NULL;
    }
    status = apr_thread_mutex_lock(m->lock);
    if (APR_SUCCESS == status) {
        apr_pool_t *stream_pool = m->spare_pool;
        
        if (!stream_pool) {
            apr_pool_create(&stream_pool, m->pool);
        }
        else {
            m->spare_pool = NULL;
        }
        
        stream = h2_stream_create(stream_id, stream_pool, m);
        stream->state = H2_STREAM_ST_OPEN;
        
        io = h2_io_set_get(m->stream_ios, stream_id);
        if (!io) {
            io = h2_io_create(stream_id, stream_pool, m->bucket_alloc);
            h2_io_set_add(m->stream_ios, io);
        }
        status = io? APR_SUCCESS : APR_ENOMEM;
        apr_thread_mutex_unlock(m->lock);
    }
    return stream;
}
Beispiel #2
0
static int stream_open(h2_session *session, int stream_id)
{
    if (session->aborted) {
        return NGHTTP2_ERR_CALLBACK_FAILURE;
    }
    h2_stream * stream = h2_stream_create(stream_id, session->pool,
                                          session->mplx);
    if (!stream) {
        ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, session->c,
                      "h2_session: stream(%ld-%d): unable to create",
                      session->id, stream_id);
        return NGHTTP2_ERR_INVALID_STREAM_ID;
    }
    
    apr_status_t status = h2_stream_set_add(session->streams, stream);
    if (status != APR_SUCCESS) {
        ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c,
                      "h2_session: stream(%ld-%d): unable to add to pool",
                      session->id, h2_stream_get_id(stream));
        return NGHTTP2_ERR_INVALID_STREAM_ID;
    }
    
    stream->state = H2_STREAM_ST_OPEN;
    ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
                  "h2_session: stream(%ld-%d): opened",
                  session->id, stream_id);
    
    h2_mplx_open_io(session->mplx, stream_id);
    return 0;
}
Beispiel #3
0
static int stream_open(h2_session *session, int stream_id)
{
    h2_stream * stream;
    apr_pool_t *stream_pool;
    if (session->aborted) {
        return NGHTTP2_ERR_CALLBACK_FAILURE;
    }
    
    if (session->spare) {
        stream_pool = session->spare;
        session->spare = NULL;
    }
    else {
        apr_pool_create(&stream_pool, session->pool);
    }
    
    stream = h2_stream_create(stream_id, stream_pool, session);
    stream->state = H2_STREAM_ST_OPEN;
    
    h2_stream_set_add(session->streams, stream);
    if (stream->id > session->max_stream_received) {
        session->max_stream_received = stream->id;
    }
    
    ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
                  "h2_session: stream(%ld-%d): opened",
                  session->id, stream_id);
    
    return 0;
}
Beispiel #4
0
h2_stream *h2_stream_open(int id, apr_pool_t *pool, h2_session *session)
{
    h2_stream *stream = h2_stream_create(id, pool, session);
    set_state(stream, H2_STREAM_ST_OPEN);
    stream->request   = h2_request_create(id, pool, session->config);
    stream->bbout     = apr_brigade_create(stream->pool, 
                                           stream->session->c->bucket_alloc);
    
    ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c,
                  "h2_stream(%ld-%d): opened", session->id, stream->id);
    return stream;
}