Esempio n. 1
0
h2_task *h2_task_create(long session_id,
                        int stream_id,
                        apr_pool_t *stream_pool,
                        h2_mplx *mplx)
{
    h2_task *task = apr_pcalloc(stream_pool, sizeof(h2_task));
    if (task == NULL) {
        ap_log_perror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, stream_pool,
                      "h2_task(%ld-%d): create stream task", 
                      session_id, stream_id);
        h2_mplx_out_close(mplx, stream_id);
        return NULL;
    }
    
    APR_RING_ELEM_INIT(task, link);

    task->id = apr_psprintf(stream_pool, "%ld-%d", session_id, stream_id);
    task->stream_id = stream_id;
    task->mplx = mplx;
    
    /* We would like to have this happening when our task is about
     * to be processed by the worker. But something corrupts our
     * stream pool if we shift this to the worker thread.
     * TODO.
     */
    task->conn = h2_conn_create(mplx->c, stream_pool);
    if (task->conn == NULL) {
        return NULL;
    }

    ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, stream_pool,
                  "h2_task(%s): created", task->id);
    return task;
}
Esempio n. 2
0
apr_status_t h2_mplx_create_task(h2_mplx *m, struct h2_stream *stream)
{
    apr_status_t status;
    AP_DEBUG_ASSERT(m);
    if (m->aborted) {
        return APR_ECONNABORTED;
    }
    status = apr_thread_mutex_lock(m->lock);
    if (APR_SUCCESS == status) {
        conn_rec *c = h2_conn_create(m->c, stream->pool);
        stream->task = h2_task_create(m->id, stream->id, 
                                      stream->pool, m, c);
        
        apr_thread_mutex_unlock(m->lock);
    }
    return status;
}
Esempio n. 3
0
h2_task *h2_task_create(long session_id, const h2_request *req, 
                        apr_pool_t *pool, h2_mplx *mplx, int eos)
{
    h2_task *task = apr_pcalloc(pool, sizeof(h2_task));
    if (task == NULL) {
        ap_log_perror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, pool,
                      APLOGNO(02941) "h2_task(%ld-%d): create stream task", 
                      session_id, req->id);
        h2_mplx_out_close(mplx, req->id, NULL);
        return NULL;
    }
    
    task->id        = apr_psprintf(pool, "%ld-%d", session_id, req->id);
    task->stream_id = req->id;
    task->pool      = pool;
    task->mplx      = mplx;
    task->c         = h2_conn_create(mplx->c, task->pool);

    task->request   = req;
    task->input_eos = eos;    
    
    return task;
}
Esempio n. 4
0
apr_status_t h2_mplx_create_task(h2_mplx *m, struct h2_stream *stream)
{
    apr_status_t status;
    AP_DEBUG_ASSERT(m);
    if (m->aborted) {
        return APR_ECONNABORTED;
    }
    status = apr_thread_mutex_lock(m->lock);
    if (APR_SUCCESS == status) {
        
        conn_rec *c = h2_conn_create(m->c, stream->pool);
        if (c == NULL) {
            ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, m->c,
                          "h2_mplx(%ld-%d): start stream",
                          m->id, stream->id);
            return APR_ENOMEM;
        }
        stream->task = h2_task_create(m->id, stream->id, 
                                      stream->pool, m, c);
        
        apr_thread_mutex_unlock(m->lock);
    }
    return status;
}