Skip to content

Commit dc75fda

Browse files
committed
Enhancement: Add close reason in VERBOSE_MODE
1 parent fbc1547 commit dc75fda

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ws.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,10 @@ static void send_ping_close(ws_cli_conn_t *cli, int threshold, int lock)
712712
ws_sendframe(cli, (const char*)ping_msg, sizeof(ping_msg), WS_FR_OP_PING);
713713

714714
/* Check previous PONG: if greater than threshold, abort. */
715-
if ((cli->current_ping_id - cli->last_pong_id) > threshold)
715+
if ((cli->current_ping_id - cli->last_pong_id) > threshold) {
716+
DEBUG("Closing, reason: many unanswered PINGs\n");
716717
close_client(cli, lock);
718+
}
717719

718720
pthread_mutex_unlock(&cli->mtx_ping);
719721
/* clang-format on */
@@ -1420,7 +1422,7 @@ static int read_single_frame(struct ws_frame_data *wfd,
14201422
if (!tmp)
14211423
{
14221424
DEBUG("Cannot allocate memory, requested: % " PRId64 "\n",
1423-
(*msg_idx + *frame_length + fsd->is_fin));
1425+
(*msg_idx + fsd->frame_length + fsd->is_fin));
14241426

14251427
wfd->error = 1;
14261428
return (-1);
@@ -1713,8 +1715,10 @@ static void *ws_establishconnection(void *vclient)
17131715
}
17141716

17151717
/* Close connectin properly. */
1716-
if (get_client_state(client) != WS_STATE_CLOSED)
1718+
if (get_client_state(client) != WS_STATE_CLOSED) {
1719+
DEBUG("Closing: normal close\n");
17171720
close_client(client, 1);
1721+
}
17181722

17191723
return (vclient);
17201724
}

0 commit comments

Comments
 (0)