Lines Matching refs:ctx
192 ((struct cf_h2_proxy_ctx *)(cf)->ctx)->call_data
194 static void cf_h2_proxy_ctx_clear(struct cf_h2_proxy_ctx *ctx) in cf_h2_proxy_ctx_clear() argument
196 struct cf_call_data save = ctx->call_data; in cf_h2_proxy_ctx_clear()
198 if(ctx->h2) { in cf_h2_proxy_ctx_clear()
199 nghttp2_session_del(ctx->h2); in cf_h2_proxy_ctx_clear()
201 Curl_bufq_free(&ctx->inbufq); in cf_h2_proxy_ctx_clear()
202 Curl_bufq_free(&ctx->outbufq); in cf_h2_proxy_ctx_clear()
203 tunnel_stream_clear(&ctx->tunnel); in cf_h2_proxy_ctx_clear()
204 memset(ctx, 0, sizeof(*ctx)); in cf_h2_proxy_ctx_clear()
205 ctx->call_data = save; in cf_h2_proxy_ctx_clear()
208 static void cf_h2_proxy_ctx_free(struct cf_h2_proxy_ctx *ctx) in cf_h2_proxy_ctx_free() argument
210 if(ctx) { in cf_h2_proxy_ctx_free()
211 cf_h2_proxy_ctx_clear(ctx); in cf_h2_proxy_ctx_free()
212 free(ctx); in cf_h2_proxy_ctx_free()
220 struct cf_h2_proxy_ctx *ctx = cf->ctx; in drain_tunnel() local
226 !Curl_bufq_is_empty(&ctx->tunnel.sendbuf)) in drain_tunnel()
278 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_client_new() local
294 rc = nghttp2_session_client_new3(&ctx->h2, cbs, cf, o, &mem); in proxy_h2_client_new()
329 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_ctx_init() local
334 DEBUGASSERT(!ctx->h2); in cf_h2_proxy_ctx_init()
335 memset(&ctx->tunnel, 0, sizeof(ctx->tunnel)); in cf_h2_proxy_ctx_init()
337 Curl_bufq_init(&ctx->inbufq, PROXY_H2_CHUNK_SIZE, PROXY_H2_NW_RECV_CHUNKS); in cf_h2_proxy_ctx_init()
338 Curl_bufq_init(&ctx->outbufq, PROXY_H2_CHUNK_SIZE, PROXY_H2_NW_SEND_CHUNKS); in cf_h2_proxy_ctx_init()
340 if(tunnel_stream_init(cf, &ctx->tunnel)) in cf_h2_proxy_ctx_init()
378 rc = nghttp2_submit_settings(ctx->h2, NGHTTP2_FLAG_NONE, iv, 3); in cf_h2_proxy_ctx_init()
387 rc = nghttp2_session_set_local_window_size(ctx->h2, NGHTTP2_FLAG_NONE, 0, in cf_h2_proxy_ctx_init()
407 static int proxy_h2_should_close_session(struct cf_h2_proxy_ctx *ctx) in proxy_h2_should_close_session() argument
409 return !nghttp2_session_want_read(ctx->h2) && in proxy_h2_should_close_session()
410 !nghttp2_session_want_write(ctx->h2); in proxy_h2_should_close_session()
416 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_nw_out_flush() local
421 if(Curl_bufq_is_empty(&ctx->outbufq)) in proxy_h2_nw_out_flush()
424 nwritten = Curl_bufq_pass(&ctx->outbufq, proxy_h2_nw_out_writer, cf, in proxy_h2_nw_out_flush()
429 Curl_bufq_len(&ctx->outbufq)); in proxy_h2_nw_out_flush()
430 ctx->nw_out_blocked = 1; in proxy_h2_nw_out_flush()
435 return Curl_bufq_is_empty(&ctx->outbufq) ? CURLE_OK : CURLE_AGAIN; in proxy_h2_nw_out_flush()
447 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_process_pending_input() local
452 while(Curl_bufq_peek(&ctx->inbufq, &buf, &blen)) { in proxy_h2_process_pending_input()
454 rv = nghttp2_session_mem_recv(ctx->h2, (const uint8_t *)buf, blen); in proxy_h2_process_pending_input()
463 Curl_bufq_skip(&ctx->inbufq, (size_t)rv); in proxy_h2_process_pending_input()
464 if(Curl_bufq_is_empty(&ctx->inbufq)) { in proxy_h2_process_pending_input()
470 "in connection buffer", Curl_bufq_len(&ctx->inbufq)); in proxy_h2_process_pending_input()
480 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_progress_ingress() local
485 if(!Curl_bufq_is_empty(&ctx->inbufq)) { in proxy_h2_progress_ingress()
487 Curl_bufq_len(&ctx->inbufq)); in proxy_h2_progress_ingress()
494 while(!ctx->conn_closed && /* not closed the connection */ in proxy_h2_progress_ingress()
495 !ctx->tunnel.closed && /* nor the tunnel */ in proxy_h2_progress_ingress()
496 Curl_bufq_is_empty(&ctx->inbufq) && /* and we consumed our input */ in proxy_h2_progress_ingress()
497 !Curl_bufq_is_full(&ctx->tunnel.recvbuf)) { in proxy_h2_progress_ingress()
499 nread = Curl_bufq_slurp(&ctx->inbufq, proxy_nw_in_reader, cf, &result); in proxy_h2_progress_ingress()
501 Curl_bufq_len(&ctx->inbufq), nread, result); in proxy_h2_progress_ingress()
510 ctx->conn_closed = TRUE; in proxy_h2_progress_ingress()
518 if(ctx->conn_closed && Curl_bufq_is_empty(&ctx->inbufq)) { in proxy_h2_progress_ingress()
528 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_progress_egress() local
531 ctx->nw_out_blocked = 0; in proxy_h2_progress_egress()
532 while(!rv && !ctx->nw_out_blocked && nghttp2_session_want_write(ctx->h2)) in proxy_h2_progress_egress()
533 rv = nghttp2_session_send(ctx->h2); in proxy_h2_progress_egress()
548 struct cf_h2_proxy_ctx *ctx = cf->ctx; in on_session_send() local
557 nwritten = Curl_bufq_write_pass(&ctx->outbufq, buf, blen, in on_session_send()
669 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_on_frame_recv() local
696 drain_tunnel(cf, data, &ctx->tunnel); in proxy_h2_on_frame_recv()
700 ctx->rcvd_goaway = TRUE; in proxy_h2_on_frame_recv()
708 if(stream_id != ctx->tunnel.stream_id) { in proxy_h2_on_frame_recv()
718 if(!ctx->tunnel.resp) in proxy_h2_on_frame_recv()
722 stream_id, ctx->tunnel.resp->status); in proxy_h2_on_frame_recv()
723 if(!ctx->tunnel.has_final_response) { in proxy_h2_on_frame_recv()
724 if(ctx->tunnel.resp->status / 100 != 1) { in proxy_h2_on_frame_recv()
725 ctx->tunnel.has_final_response = TRUE; in proxy_h2_on_frame_recv()
731 drain_tunnel(cf, data, &ctx->tunnel); in proxy_h2_on_frame_recv()
748 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_on_header() local
757 if(stream_id != ctx->tunnel.stream_id) { in proxy_h2_on_header()
767 if(ctx->tunnel.has_final_response) { in proxy_h2_on_header()
786 resp->prev = ctx->tunnel.resp; in proxy_h2_on_header()
787 ctx->tunnel.resp = resp; in proxy_h2_on_header()
789 stream_id, ctx->tunnel.resp->status); in proxy_h2_on_header()
793 if(!ctx->tunnel.resp) in proxy_h2_on_header()
796 result = Curl_dynhds_add(&ctx->tunnel.resp->headers, in proxy_h2_on_header()
816 struct cf_h2_proxy_ctx *ctx = cf->ctx; in tunnel_send_callback() local
824 (void)ctx; in tunnel_send_callback()
832 DEBUGASSERT(ts == &ctx->tunnel); in tunnel_send_callback()
853 struct cf_h2_proxy_ctx *ctx = cf->ctx; in tunnel_recv_callback() local
861 if(stream_id != ctx->tunnel.stream_id) in tunnel_recv_callback()
864 nwritten = Curl_bufq_write(&ctx->tunnel.recvbuf, mem, len, &result); in tunnel_recv_callback()
879 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_on_stream_close() local
885 if(stream_id != ctx->tunnel.stream_id) in proxy_h2_on_stream_close()
890 ctx->tunnel.closed = TRUE; in proxy_h2_on_stream_close()
891 ctx->tunnel.error = error_code; in proxy_h2_on_stream_close()
956 struct cf_h2_proxy_ctx *ctx = cf->ctx; in submit_CONNECT() local
969 result = proxy_h2_submit(&ts->stream_id, cf, data, ctx->h2, req, in submit_CONNECT()
1029 struct cf_h2_proxy_ctx *ctx = cf->ctx; in H2_CONNECT() local
1084 if((result && (result != CURLE_AGAIN)) || ctx->tunnel.closed) in H2_CONNECT()
1093 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_connect() local
1097 struct tunnel_stream *ts = &ctx->tunnel; in cf_h2_proxy_connect()
1114 if(!ctx->h2) { in cf_h2_proxy_connect()
1147 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_close() local
1149 if(ctx) { in cf_h2_proxy_close()
1153 cf_h2_proxy_ctx_clear(ctx); in cf_h2_proxy_close()
1163 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_destroy() local
1166 if(ctx) { in cf_h2_proxy_destroy()
1167 cf_h2_proxy_ctx_free(ctx); in cf_h2_proxy_destroy()
1168 cf->ctx = NULL; in cf_h2_proxy_destroy()
1175 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_shutdown() local
1180 if(!cf->connected || !ctx->h2 || cf->shutdown || ctx->conn_closed) { in cf_h2_proxy_shutdown()
1187 if(!ctx->sent_goaway) { in cf_h2_proxy_shutdown()
1188 rv = nghttp2_submit_goaway(ctx->h2, NGHTTP2_FLAG_NONE, in cf_h2_proxy_shutdown()
1198 ctx->sent_goaway = TRUE; in cf_h2_proxy_shutdown()
1202 if(nghttp2_session_want_write(ctx->h2)) in cf_h2_proxy_shutdown()
1204 if(!result && nghttp2_session_want_read(ctx->h2)) in cf_h2_proxy_shutdown()
1207 *done = (ctx->conn_closed || in cf_h2_proxy_shutdown()
1208 (!result && !nghttp2_session_want_write(ctx->h2) && in cf_h2_proxy_shutdown()
1209 !nghttp2_session_want_read(ctx->h2))); in cf_h2_proxy_shutdown()
1219 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_data_pending() local
1220 if((ctx && !Curl_bufq_is_empty(&ctx->inbufq)) || in cf_h2_proxy_data_pending()
1221 (ctx && ctx->tunnel.state == H2_TUNNEL_ESTABLISHED && in cf_h2_proxy_data_pending()
1222 !Curl_bufq_is_empty(&ctx->tunnel.recvbuf))) in cf_h2_proxy_data_pending()
1231 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_adjust_pollset() local
1236 if(!cf->connected && ctx->h2) { in cf_h2_proxy_adjust_pollset()
1237 want_send = nghttp2_session_want_write(ctx->h2) || in cf_h2_proxy_adjust_pollset()
1238 !Curl_bufq_is_empty(&ctx->outbufq) || in cf_h2_proxy_adjust_pollset()
1239 !Curl_bufq_is_empty(&ctx->tunnel.sendbuf); in cf_h2_proxy_adjust_pollset()
1240 want_recv = nghttp2_session_want_read(ctx->h2); in cf_h2_proxy_adjust_pollset()
1245 if(ctx->h2 && (want_recv || want_send)) { in cf_h2_proxy_adjust_pollset()
1249 c_exhaust = !nghttp2_session_get_remote_window_size(ctx->h2); in cf_h2_proxy_adjust_pollset()
1250 s_exhaust = ctx->tunnel.stream_id >= 0 && in cf_h2_proxy_adjust_pollset()
1252 ctx->h2, ctx->tunnel.stream_id); in cf_h2_proxy_adjust_pollset()
1255 (!c_exhaust && nghttp2_session_want_write(ctx->h2)) || in cf_h2_proxy_adjust_pollset()
1256 !Curl_bufq_is_empty(&ctx->outbufq) || in cf_h2_proxy_adjust_pollset()
1257 !Curl_bufq_is_empty(&ctx->tunnel.sendbuf); in cf_h2_proxy_adjust_pollset()
1264 else if(ctx->sent_goaway && !cf->shutdown) { in cf_h2_proxy_adjust_pollset()
1267 want_send = nghttp2_session_want_write(ctx->h2) || in cf_h2_proxy_adjust_pollset()
1268 !Curl_bufq_is_empty(&ctx->outbufq) || in cf_h2_proxy_adjust_pollset()
1269 !Curl_bufq_is_empty(&ctx->tunnel.sendbuf); in cf_h2_proxy_adjust_pollset()
1270 want_recv = nghttp2_session_want_read(ctx->h2); in cf_h2_proxy_adjust_pollset()
1282 struct cf_h2_proxy_ctx *ctx = cf->ctx; in h2_handle_tunnel_close() local
1285 if(ctx->tunnel.error == NGHTTP2_REFUSED_STREAM) { in h2_handle_tunnel_close()
1287 "connection", ctx->tunnel.stream_id); in h2_handle_tunnel_close()
1292 else if(ctx->tunnel.error != NGHTTP2_NO_ERROR) { in h2_handle_tunnel_close()
1294 ctx->tunnel.stream_id, nghttp2_http2_strerror(ctx->tunnel.error), in h2_handle_tunnel_close()
1295 ctx->tunnel.error); in h2_handle_tunnel_close()
1299 else if(ctx->tunnel.reset) { in h2_handle_tunnel_close()
1300 failf(data, "HTTP/2 stream %u was reset", ctx->tunnel.stream_id); in h2_handle_tunnel_close()
1308 ctx->tunnel.stream_id, rv, *err); in h2_handle_tunnel_close()
1315 struct cf_h2_proxy_ctx *ctx = cf->ctx; in tunnel_recv() local
1319 if(!Curl_bufq_is_empty(&ctx->tunnel.recvbuf)) { in tunnel_recv()
1320 nread = Curl_bufq_read(&ctx->tunnel.recvbuf, in tunnel_recv()
1328 if(ctx->tunnel.closed) { in tunnel_recv()
1331 else if(ctx->tunnel.reset || in tunnel_recv()
1332 (ctx->conn_closed && Curl_bufq_is_empty(&ctx->inbufq)) || in tunnel_recv()
1333 (ctx->rcvd_goaway && in tunnel_recv()
1334 ctx->last_stream_id < ctx->tunnel.stream_id)) { in tunnel_recv()
1346 ctx->tunnel.stream_id, len, nread, *err); in tunnel_recv()
1354 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_recv() local
1359 if(ctx->tunnel.state != H2_TUNNEL_ESTABLISHED) { in cf_h2_proxy_recv()
1365 if(Curl_bufq_is_empty(&ctx->tunnel.recvbuf)) { in cf_h2_proxy_recv()
1375 ctx->tunnel.stream_id, nread); in cf_h2_proxy_recv()
1376 nghttp2_session_consume(ctx->h2, ctx->tunnel.stream_id, (size_t)nread); in cf_h2_proxy_recv()
1386 if(!Curl_bufq_is_empty(&ctx->tunnel.recvbuf) && in cf_h2_proxy_recv()
1390 drain_tunnel(cf, data, &ctx->tunnel); in cf_h2_proxy_recv()
1393 ctx->tunnel.stream_id, len, nread, *err); in cf_h2_proxy_recv()
1403 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_send() local
1410 if(ctx->tunnel.state != H2_TUNNEL_ESTABLISHED) { in cf_h2_proxy_send()
1416 if(ctx->tunnel.closed) { in cf_h2_proxy_send()
1422 nwritten = Curl_bufq_write(&ctx->tunnel.sendbuf, buf, len, err); in cf_h2_proxy_send()
1427 if(!Curl_bufq_is_empty(&ctx->tunnel.sendbuf)) { in cf_h2_proxy_send()
1429 rv = nghttp2_session_resume_data(ctx->h2, ctx->tunnel.stream_id); in cf_h2_proxy_send()
1453 if(proxy_h2_should_close_session(ctx)) { in cf_h2_proxy_send()
1456 if(ctx->tunnel.closed) { in cf_h2_proxy_send()
1468 if(!Curl_bufq_is_empty(&ctx->tunnel.recvbuf) && in cf_h2_proxy_send()
1472 drain_tunnel(cf, data, &ctx->tunnel); in cf_h2_proxy_send()
1476 ctx->tunnel.stream_id, len, nwritten, *err, in cf_h2_proxy_send()
1478 ctx->h2, ctx->tunnel.stream_id), in cf_h2_proxy_send()
1479 nghttp2_session_get_remote_window_size(ctx->h2), in cf_h2_proxy_send()
1480 Curl_bufq_len(&ctx->tunnel.sendbuf), in cf_h2_proxy_send()
1481 Curl_bufq_len(&ctx->outbufq)); in cf_h2_proxy_send()
1489 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_flush() local
1494 if(!Curl_bufq_is_empty(&ctx->tunnel.sendbuf)) { in cf_h2_proxy_flush()
1496 int rv = nghttp2_session_resume_data(ctx->h2, ctx->tunnel.stream_id); in cf_h2_proxy_flush()
1508 ctx->tunnel.stream_id, result, in cf_h2_proxy_flush()
1510 ctx->h2, ctx->tunnel.stream_id), in cf_h2_proxy_flush()
1511 nghttp2_session_get_remote_window_size(ctx->h2), in cf_h2_proxy_flush()
1512 Curl_bufq_len(&ctx->tunnel.sendbuf), in cf_h2_proxy_flush()
1513 Curl_bufq_len(&ctx->outbufq)); in cf_h2_proxy_flush()
1522 struct cf_h2_proxy_ctx *ctx = cf->ctx; in proxy_h2_connisalive() local
1537 nread = Curl_bufq_slurp(&ctx->inbufq, proxy_nw_in_reader, cf, &result); in proxy_h2_connisalive()
1543 alive = !proxy_h2_should_close_session(ctx); in proxy_h2_connisalive()
1559 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_is_alive() local
1564 result = (ctx && ctx->h2 && proxy_h2_connisalive(cf, data, input_pending)); in cf_h2_proxy_is_alive()
1575 struct cf_h2_proxy_ctx *ctx = cf->ctx; in cf_h2_proxy_query() local
1579 if(!Curl_bufq_is_empty(&ctx->outbufq) || in cf_h2_proxy_query()
1580 !Curl_bufq_is_empty(&ctx->tunnel.sendbuf)) { in cf_h2_proxy_query()
1640 struct cf_h2_proxy_ctx *ctx; in Curl_cf_h2_proxy_insert_after() local
1644 ctx = calloc(1, sizeof(*ctx)); in Curl_cf_h2_proxy_insert_after()
1645 if(!ctx) in Curl_cf_h2_proxy_insert_after()
1648 result = Curl_cf_create(&cf_h2_proxy, &Curl_cft_h2_proxy, ctx); in Curl_cf_h2_proxy_insert_after()
1657 cf_h2_proxy_ctx_free(ctx); in Curl_cf_h2_proxy_insert_after()