| 911 | static /* atomic */ apr_uint32_t next_id; |
| 912 | |
| 913 | apr_status_t h2_session_create(h2_session **psession, conn_rec *c, request_rec *r, |
| 914 | server_rec *s, h2_workers *workers) |
| 915 | { |
| 916 | nghttp2_session_callbacks *callbacks = NULL; |
| 917 | nghttp2_option *options = NULL; |
| 918 | uint32_t n; |
| 919 | int thread_num; |
| 920 | apr_pool_t *pool = NULL; |
| 921 | h2_session *session; |
| 922 | h2_stream *stream0; |
| 923 | apr_status_t status; |
| 924 | int rv; |
| 925 | |
| 926 | *psession = NULL; |
| 927 | apr_pool_create(&pool, c->pool); |
| 928 | apr_pool_tag(pool, "h2_session"); |
| 929 | session = apr_pcalloc(pool, sizeof(h2_session)); |
| 930 | if (!session) { |
| 931 | return APR_ENOMEM; |
| 932 | } |
| 933 | |
| 934 | *psession = session; |
| 935 | /* c->id does not give a unique id for the lifetime of the session. |
| 936 | * mpms like event change c->id when re-activating a keepalive |
| 937 | * connection based on the child_num+thread_num of the worker |
| 938 | * processing it. |
| 939 | * We'd like to have an id that remains constant and unique bc |
| 940 | * h2 streams can live through keepalive periods. While double id |
| 941 | * will not lead to processing failures, it will confuse log analysis. |
| 942 | */ |
| 943 | #if AP_MODULE_MAGIC_AT_LEAST(20211221, 8) |
| 944 | ap_sb_get_child_thread(c->sbh, &session->child_num, &thread_num); |
| 945 | #else |
| 946 | (void)thread_num; |
| 947 | session->child_num = (int)getpid(); |
| 948 | #endif |
| 949 | session->id = apr_atomic_inc32(&next_id); |
| 950 | session->c1 = c; |
| 951 | session->r = r; |
| 952 | session->s = s; |
| 953 | session->pool = pool; |
| 954 | session->workers = workers; |
| 955 | |
| 956 | session->state = H2_SESSION_ST_INIT; |
| 957 | session->local.accepting = 1; |
| 958 | session->remote.accepting = 1; |
| 959 | |
| 960 | session->max_stream_count = h2_config_sgeti(s, H2_CONF_MAX_STREAMS); |
| 961 | session->max_stream_mem = h2_config_sgeti(s, H2_CONF_STREAM_MAX_MEM); |
| 962 | session->max_data_frame_len = h2_config_sgeti(s, H2_CONF_MAX_DATA_FRAME_LEN); |
| 963 | session->max_stream_errors = h2_config_sgeti(s, H2_CONF_MAX_STREAM_ERRORS); |
| 964 | |
| 965 | session->out_c1_blocked = h2_iq_create(session->pool, (int)session->max_stream_count); |
| 966 | session->ready_to_process = h2_iq_create(session->pool, (int)session->max_stream_count); |
| 967 | |
| 968 | session->monitor = apr_pcalloc(pool, sizeof(h2_stream_monitor)); |
| 969 | session->monitor->ctx = session; |
| 970 | session->monitor->on_state_enter = on_stream_state_enter; |
no test coverage detected