Skip to content

Commit

Permalink
Call ws_close_if_able instead of ws_client_free in worker.c
Browse files Browse the repository at this point in the history
Update last call to ws_client_free to use ws_close_if_able instead, from
worker.c
  • Loading branch information
jessie-murray committed Dec 5, 2021
1 parent 887e0ec commit 6539ae1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ws_client_new(struct http_client *http_client) {
return ws;
}

void
static void
ws_client_free(struct ws_client *ws) {

/* mark WS client as closing to skip the Redis callback */
Expand Down Expand Up @@ -558,7 +558,7 @@ ws_frame_and_send_response(struct ws_client *ws, enum ws_frame_type frame_type,
return ws_schedule_write(ws);
}

static void
void
ws_close_if_able(struct ws_client *ws) {

ws->close_after_events = 1; /* note that we're closing */
Expand Down
6 changes: 3 additions & 3 deletions src/websocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ struct ws_client {
struct ws_client *
ws_client_new(struct http_client *http_client);

void
ws_client_free(struct ws_client *ws);

int
ws_handshake_reply(struct ws_client *ws);

Expand All @@ -61,4 +58,7 @@ ws_process_read_data(struct ws_client *ws, unsigned int *out_processed);
int
ws_frame_and_send_response(struct ws_client *ws, enum ws_frame_type type, const char *p, size_t sz);

void
ws_close_if_able(struct ws_client *ws);

#endif
2 changes: 1 addition & 1 deletion src/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ worker_can_read(int fd, short event, void *p) {
int reply_ret = ws_handshake_reply(c->ws);
if(reply_ret < 0) {
c->ws->http_client = NULL; /* detach to prevent double free */
ws_client_free(c->ws);
ws_close_if_able(c->ws);
c->broken = 1;
} else {
unsigned int processed = 0;
Expand Down

0 comments on commit 6539ae1

Please sign in to comment.