Skip to content

Commit

Permalink
move comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragos Oancea committed Oct 21, 2023
1 parent 13bce73 commit ea4dce0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/kws.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,15 +1039,15 @@ KS_DECLARE(ks_ssize_t) kws_close(kws_t *kws, int16_t reason)

if (kws->handshake && kws->sock != KS_SOCK_INVALID) {
uint16_t *u16;
int16_t got_reason = reason ? reason : WS_NORMAL_CLOSE;
int16_t got_reason = reason ? reason : WS_NORMAL_CLOSE /* regular close initiated by us */;

if (kws->type == KWS_CLIENT) {
const uint8_t maskb = 0x80;
uint8_t size = 0x02, fr[8] = {WSOC_CLOSE | 0x80, size | maskb, 0, 0, 0, 0, 0, 0}, masking_key[4], i;
uint8_t *p;

u16 = (uint16_t *) &fr[6];
*u16 = htons((int16_t)got_reason); /* regular close initiated by us */
*u16 = htons((int16_t)got_reason);
p = (uint8_t *)u16; /*use p for masking the reason which is the payload */

gen_nonce(masking_key, 4);
Expand Down

0 comments on commit ea4dce0

Please sign in to comment.