static int stream_open(h2_session *session, int stream_id) { h2_stream * stream; if (session->aborted) { return NGHTTP2_ERR_CALLBACK_FAILURE; } stream = h2_mplx_open_io(session->mplx, stream_id); if (stream) { 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; } ap_log_cerror(APLOG_MARK, APLOG_ERR, APR_ENOMEM, session->c, APLOGNO(02918) "h2_session: stream(%ld-%d): unable to create", session->id, stream_id); return NGHTTP2_ERR_INVALID_STREAM_ID; }
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; }
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; }
apr_status_t h2_mplx_cleanup_stream(h2_mplx *m, h2_stream *stream) { AP_DEBUG_ASSERT(m); apr_status_t status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = h2_io_set_get(m->stream_ios, stream->id); if (!io || io->task_done) { /* No more io or task already done -> cleanup immediately */ stream_destroy(m, stream, io); } else { /* Add stream to closed set for cleanup when task is done */ h2_stream_set_add(m->closed, stream); } apr_thread_mutex_unlock(m->lock); } return status; }
static apr_status_t close_active_stream(h2_session *session, h2_stream *stream, int join) { apr_status_t status = APR_SUCCESS; ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, "h2_stream(%ld-%d): closing", session->id, (int)stream->id); h2_stream_set_remove(session->streams, stream); if (session->before_stream_close_cb && stream->task) { status = session->before_stream_close_cb(session, stream, stream->task, join); } if (status == APR_SUCCESS) { h2_mplx_close_io(session->mplx, stream->id); h2_stream_destroy(stream); } else if (status == APR_EAGAIN) { h2_stream_set_add(session->zombies, stream); } return status; }