Skip to content

Commit

Permalink
fixup! Websocket simple proxy protocol implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksey Mikhaylov <aym@tempesta-tech.com>
  • Loading branch information
ttaym committed Mar 24, 2022
1 parent 7ed8467 commit f14cdf8
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions fw/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -2276,21 +2276,18 @@ TfwMsg *
tfw_http_conn_msg_alloc(TfwConn *conn, TfwStream *stream)
{
int type = TFW_CONN_TYPE(conn);
TfwHttpMsg *hm = __tfw_http_msg_alloc(type,
type & TFW_FSM_WS ? false : true);
TfwHttpMsg *hm = __tfw_http_msg_alloc(type, true);
if (unlikely(!hm))
return NULL;

hm->conn = conn;
tfw_connection_get(conn);
hm->stream = stream;

if (!(type & TFW_FSM_WS)) {
if (type & Conn_Clnt)
tfw_http_init_parser_req((TfwHttpReq *)hm);
else
tfw_http_init_parser_resp((TfwHttpResp *)hm);
}
if (type & Conn_Clnt)
tfw_http_init_parser_req((TfwHttpReq *)hm);
else
tfw_http_init_parser_resp((TfwHttpResp *)hm);

if (TFW_CONN_H2(conn)) {
TfwHttpReq *req = (TfwHttpReq *)hm;
Expand All @@ -2306,25 +2303,23 @@ tfw_http_conn_msg_alloc(TfwConn *conn, TfwStream *stream)
if (type & Conn_Clnt) {
TFW_INC_STAT_BH(clnt.rx_messages);
} else {
if (!(type & TFW_FSM_WS)) {
if (unlikely(tfw_http_resp_pair(hm)))
goto clean;
if (unlikely(tfw_http_resp_pair(hm)))
goto clean;

if (TFW_MSG_H2(hm->req)) {
size_t sz = TFW_HDR_MAP_SZ(TFW_HDR_MAP_INIT_CNT);
TfwHttpTransIter *mit =
&((TfwHttpResp *)hm)->mit;

if (TFW_MSG_H2(hm->req)) {
size_t sz = TFW_HDR_MAP_SZ(TFW_HDR_MAP_INIT_CNT);
TfwHttpTransIter *mit =
&((TfwHttpResp *)hm)->mit;

mit->map = tfw_pool_alloc(hm->pool, sz);
if (unlikely(!mit->map)) {
T_WARN("HTTP/2: unable to allocate"
"memory for response header "
"map\n");
goto clean;
}
mit->map->size = TFW_HDR_MAP_INIT_CNT;
mit->map->count = 0;
mit->map = tfw_pool_alloc(hm->pool, sz);
if (unlikely(!mit->map)) {
T_WARN("HTTP/2: unable to allocate"
"memory for response header "
"map\n");
goto clean;
}
mit->map->size = TFW_HDR_MAP_INIT_CNT;
mit->map->count = 0;
}

TFW_INC_STAT_BH(serv.rx_messages);
Expand Down

0 comments on commit f14cdf8

Please sign in to comment.