From 6efb59e79be0cae7ce7127fba24b760157d08993 Mon Sep 17 00:00:00 2001 From: Radkesvat <134321679+radkesvat@users.noreply.github.com> Date: Fri, 12 Jul 2024 09:01:17 +0000 Subject: [PATCH] Finish new http2, bugs fixed, renamed enums --- tunnels/client/http2/http2_client.c | 12 ++++++++---- tunnels/client/http2/types.h | 5 ++--- tunnels/server/http2/http2_server.c | 4 ++-- tunnels/server/http2/types.h | 6 +++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tunnels/client/http2/http2_client.c b/tunnels/client/http2/http2_client.c index f38823b4..ba01a90f 100644 --- a/tunnels/client/http2/http2_client.c +++ b/tunnels/client/http2/http2_client.c @@ -14,6 +14,7 @@ enum static int onStreamClosedCallback(nghttp2_session *session, int32_t stream_id, uint32_t error_code, void *userdata) { (void) error_code; + (void) userdata; http2_client_con_state_t *con = (http2_client_con_state_t *) userdata; http2_client_child_con_state_t *stream = nghttp2_session_get_stream_user_data(session, stream_id); @@ -40,7 +41,7 @@ static void flushWriteQueue(http2_client_con_state_t *con) http2_client_child_con_state_t *stream = CSTATE(stream_context); lockLine(stream->line); - action_queue_t_push(&con->actions, (http2_action_t) {.action_id = kActionStreamData, + action_queue_t_push(&con->actions, (http2_action_t) {.action_id = kActionConData, .stream_line = stream->line, .buf = stream_context->payload}); } @@ -110,7 +111,7 @@ static int onDataChunkRecvCallback(nghttp2_session *session, uint8_t flags, int3 lockLine(stream->line); action_queue_t_push(&con->actions, - (http2_action_t) {.action_id = kActionStreamData, .stream_line = stream->line, .buf = buf}); + (http2_action_t) {.action_id = kActionStreamDataReceived, .stream_line = stream->line, .buf = buf}); return 0; } @@ -322,7 +323,7 @@ static void doHttp2Action(const http2_action_t action, http2_client_con_state_t break; - case kActionStreamData: { + case kActionStreamDataReceived: { if (con->content_type == kApplicationGrpc) { bufferStreamPush(stream->grpc_buffer_stream, action.buf); @@ -392,7 +393,10 @@ static void doHttp2Action(const http2_action_t action, http2_client_con_state_t dest->downStream(dest, fc); } break; - + case kActionConData: { + sendStreamData(con,stream,action.buf); + } + break; case kActionInvalid: LOGF("incorrect http2 action id"); exit(1); diff --git a/tunnels/client/http2/types.h b/tunnels/client/http2/types.h index 2d01a072..b899b4ca 100644 --- a/tunnels/client/http2/types.h +++ b/tunnels/client/http2/types.h @@ -19,9 +19,8 @@ enum http2_actions kActionInvalid, kActionStreamEst, kActionStreamFinish, - kActionStreamData, - kActionConData, - kActionConFinish + kActionStreamDataReceived, + kActionConData }; typedef struct http2_action_s diff --git a/tunnels/server/http2/http2_server.c b/tunnels/server/http2/http2_server.c index 9d51fa6e..7832ea97 100644 --- a/tunnels/server/http2/http2_server.c +++ b/tunnels/server/http2/http2_server.c @@ -99,7 +99,7 @@ static int onDataChunkRecvCallback(nghttp2_session *session, uint8_t flags, int3 lockLine(stream->line); action_queue_t_push(&con->actions, - (http2_action_t) {.action_id = kActionStreamData, .stream_line = stream->line, .buf = buf}); + (http2_action_t) {.action_id = kActionStreamDataReceived, .stream_line = stream->line, .buf = buf}); return 0; } @@ -316,7 +316,7 @@ static void doHttp2Action(const http2_action_t action, http2_server_con_state_t break; - case kActionStreamData: { + case kActionStreamDataReceived: { if (con->content_type == kApplicationGrpc) { bufferStreamPush(stream->grpc_buffer_stream, action.buf); diff --git a/tunnels/server/http2/types.h b/tunnels/server/http2/types.h index 12dd9362..ca9913f1 100644 --- a/tunnels/server/http2/types.h +++ b/tunnels/server/http2/types.h @@ -17,9 +17,9 @@ enum http2_actions kActionInvalid, kActionStreamInit, kActionStreamFinish, - kActionStreamData, - kActionConData, - kActionConFinish + kActionStreamDataReceived, + kActionConData + // kActionConFinish }; typedef struct http2_action_s