nxt_unit.c (1559:c104a0129a14) nxt_unit.c (1590:b479e8ec1e36)
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6#include <stdlib.h>
7
8#include "nxt_main.h"

--- 3274 unchanged lines hidden (view full) ---

3283 return res;
3284}
3285
3286
3287int
3288nxt_unit_websocket_retain(nxt_unit_websocket_frame_t *ws)
3289{
3290 char *b;
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6#include <stdlib.h>
7
8#include "nxt_main.h"

--- 3274 unchanged lines hidden (view full) ---

3283 return res;
3284}
3285
3286
3287int
3288nxt_unit_websocket_retain(nxt_unit_websocket_frame_t *ws)
3289{
3290 char *b;
3291 size_t size;
3291 size_t size, hsize;
3292 nxt_unit_websocket_frame_impl_t *ws_impl;
3293
3294 ws_impl = nxt_container_of(ws, nxt_unit_websocket_frame_impl_t, ws);
3295
3296 if (ws_impl->buf->free_ptr != NULL || ws_impl->buf->hdr != NULL) {
3297 return NXT_UNIT_OK;
3298 }
3299
3300 size = ws_impl->buf->buf.end - ws_impl->buf->buf.start;
3301
3302 b = malloc(size);
3303 if (nxt_slow_path(b == NULL)) {
3304 return NXT_UNIT_ERROR;
3305 }
3306
3307 memcpy(b, ws_impl->buf->buf.start, size);
3308
3292 nxt_unit_websocket_frame_impl_t *ws_impl;
3293
3294 ws_impl = nxt_container_of(ws, nxt_unit_websocket_frame_impl_t, ws);
3295
3296 if (ws_impl->buf->free_ptr != NULL || ws_impl->buf->hdr != NULL) {
3297 return NXT_UNIT_OK;
3298 }
3299
3300 size = ws_impl->buf->buf.end - ws_impl->buf->buf.start;
3301
3302 b = malloc(size);
3303 if (nxt_slow_path(b == NULL)) {
3304 return NXT_UNIT_ERROR;
3305 }
3306
3307 memcpy(b, ws_impl->buf->buf.start, size);
3308
3309 hsize = nxt_websocket_frame_header_size(b);
3310
3309 ws_impl->buf->buf.start = b;
3311 ws_impl->buf->buf.start = b;
3310 ws_impl->buf->buf.free = b;
3312 ws_impl->buf->buf.free = b + hsize;
3311 ws_impl->buf->buf.end = b + size;
3312
3313 ws_impl->buf->free_ptr = b;
3314
3313 ws_impl->buf->buf.end = b + size;
3314
3315 ws_impl->buf->free_ptr = b;
3316
3317 ws_impl->ws.header = (nxt_websocket_header_t *) b;
3318
3319 if (ws_impl->ws.header->mask) {
3320 ws_impl->ws.mask = (uint8_t *) b + hsize - 4;
3321
3322 } else {
3323 ws_impl->ws.mask = NULL;
3324 }
3325
3315 return NXT_UNIT_OK;
3316}
3317
3318
3319void
3320nxt_unit_websocket_done(nxt_unit_websocket_frame_t *ws)
3321{
3322 nxt_unit_websocket_frame_release(ws);

--- 3013 unchanged lines hidden ---
3326 return NXT_UNIT_OK;
3327}
3328
3329
3330void
3331nxt_unit_websocket_done(nxt_unit_websocket_frame_t *ws)
3332{
3333 nxt_unit_websocket_frame_release(ws);

--- 3013 unchanged lines hidden ---