Skip to content

Commit

Permalink
fixup! Websockets over http/1.1 minor fixes
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 Apr 21, 2022
1 parent e9a5305 commit a0b51d2
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions fw/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -5038,6 +5038,12 @@ tfw_http_req_cache_cb(TfwHttpMsg *msg)
/* Account current request in APM health monitoring statistics */
tfw_http_hm_srv_update((TfwServer *)srv_conn->peer, req);

/* We set TFW_CONN_B_UNSCHED on server connection. New requests must
* not be scheduled to it. It will be used only for websocket transport.
* If upgrade will fail, we clear it. */
if (test_bit(TFW_HTTP_B_UPGRADE_WEBSOCKET, req->flags)) {
set_bit(TFW_CONN_B_UNSCHED, &srv_conn->flags);
}
/* Forward request to the server. */
tfw_http_req_fwd_resched(srv_conn, req, &eq);
tfw_http_req_zap_error(&eq);
Expand Down Expand Up @@ -6215,6 +6221,10 @@ int
tfw_http_msg_process_generic(TfwConn *conn, TfwStream *stream,
struct sk_buff *skb)
{
int r;
TfwHttpMsg *req;
bool websocket = false;

if (WARN_ON_ONCE(!stream))
return -EINVAL;
if (unlikely(!stream->msg)) {
Expand All @@ -6231,9 +6241,24 @@ tfw_http_msg_process_generic(TfwConn *conn, TfwStream *stream,
T_DBG2("Add skb %p to message %p\n", skb, stream->msg);
ss_skb_queue_tail(&stream->msg->skb_head, skb);

return (TFW_CONN_TYPE(conn) & Conn_Clnt)
? tfw_http_req_process(conn, stream, skb)
: tfw_http_resp_process(conn, stream, skb);
if (TFW_CONN_TYPE(conn) & Conn_Clnt)
return tfw_http_req_process(conn, stream, skb);

/* That is paired request, it may be freed after resp processing */
req = ((TfwHttpMsg *)stream->msg)->pair;
websocket = test_bit(TFW_HTTP_B_UPGRADE_WEBSOCKET, req->flags);
if ((r = tfw_http_resp_process(conn, stream, skb))) {
TfwSrvConn *srv_conn = (TfwSrvConn *)conn;
/*
* We must clear TFW_CONN_B_UNSCHED to make server connection
* available for request scheduling further if websocket upgrade
* request failed.
*/
if (websocket)
clear_bit(TFW_CONN_B_UNSCHED, &srv_conn->flags);
}

return r;
}

/**
Expand Down

0 comments on commit a0b51d2

Please sign in to comment.