Skip to content

Commit

Permalink
common: optimize send pong
Browse files Browse the repository at this point in the history
  • Loading branch information
liudongmiao committed Apr 12, 2024
1 parent d8576c6 commit d1057eb
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,10 @@ static void send_pong(struct evbuffer *src, uint16_t payload_size, uint32_t mask
char header[MAX_WS_HEADER_SIZE];
char buffer[MAX_CONTROL_FRAME_SIZE];
} wss_frame_pong;
uint16_t remain_size, size = 0;
uint16_t size = 0;
if (payload_size > 0) {
size = evbuffer_remove(src, wss_frame_pong.buffer, MIN(MAX_CONTROL_FRAME_SIZE, payload_size));
}
if ((remain_size = payload_size - size) > 0) {
evbuffer_drain(src, remain_size);
LOGD("pong frame too large: %u", payload_size);
return;
size = evbuffer_copyout(src, wss_frame_pong.buffer, MIN(MAX_CONTROL_FRAME_SIZE, payload_size));
evbuffer_drain(src, payload_size);
}
#ifdef WSS_PROXY_CLIENT
(void) mask_key;
Expand Down

0 comments on commit d1057eb

Please sign in to comment.