Skip to content

Commit

Permalink
lwan_response_websocket_read() should return errno on recv() failure
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereira committed Sep 21, 2024
1 parent c0d3224 commit 5528ec7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/lib/lwan-websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ int lwan_response_websocket_read_hint(struct lwan_request *request,
uint16_t header;
bool continuation = false;

if (!(request->conn->flags & CONN_IS_WEBSOCKET))
if (UNLIKELY(!(request->conn->flags & CONN_IS_WEBSOCKET)))
return ENOTCONN;

lwan_strbuf_reset_trim(request->response.buffer, size_hint);
Expand All @@ -345,9 +345,8 @@ int lwan_response_websocket_read_hint(struct lwan_request *request,

ssize_t r = lwan_recv(request, &header, sizeof(header),
MSG_DONTWAIT | MSG_NOSIGNAL);
if (r < 0) {
return (int)-r;
}
if (UNLIKELY(r < 0))
return errno;
header = htons(header);
continuation = false;

Expand Down

0 comments on commit 5528ec7

Please sign in to comment.