nxt_unit.c (1618:ad6c036ae63c) nxt_unit.c (1623:7cdddbe0fb45)
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6#include <stdlib.h>
7
8#include "nxt_main.h"

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

69static int nxt_unit_process_shm_ack(nxt_unit_ctx_t *ctx);
70static nxt_unit_request_info_impl_t *nxt_unit_request_info_get(
71 nxt_unit_ctx_t *ctx);
72static void nxt_unit_request_info_release(nxt_unit_request_info_t *req);
73static void nxt_unit_request_info_free(nxt_unit_request_info_impl_t *req);
74static nxt_unit_websocket_frame_impl_t *nxt_unit_websocket_frame_get(
75 nxt_unit_ctx_t *ctx);
76static void nxt_unit_websocket_frame_release(nxt_unit_websocket_frame_t *ws);
1
2/*
3 * Copyright (C) NGINX, Inc.
4 */
5
6#include <stdlib.h>
7
8#include "nxt_main.h"

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

69static int nxt_unit_process_shm_ack(nxt_unit_ctx_t *ctx);
70static nxt_unit_request_info_impl_t *nxt_unit_request_info_get(
71 nxt_unit_ctx_t *ctx);
72static void nxt_unit_request_info_release(nxt_unit_request_info_t *req);
73static void nxt_unit_request_info_free(nxt_unit_request_info_impl_t *req);
74static nxt_unit_websocket_frame_impl_t *nxt_unit_websocket_frame_get(
75 nxt_unit_ctx_t *ctx);
76static void nxt_unit_websocket_frame_release(nxt_unit_websocket_frame_t *ws);
77static void nxt_unit_websocket_frame_free(nxt_unit_websocket_frame_impl_t *ws);
77static void nxt_unit_websocket_frame_free(nxt_unit_ctx_t *ctx,
78 nxt_unit_websocket_frame_impl_t *ws);
78static nxt_unit_mmap_buf_t *nxt_unit_mmap_buf_get(nxt_unit_ctx_t *ctx);
79static void nxt_unit_mmap_buf_release(nxt_unit_mmap_buf_t *mmap_buf);
80static int nxt_unit_mmap_buf_send(nxt_unit_request_info_t *req,
81 nxt_unit_mmap_buf_t *mmap_buf, int last);
82static void nxt_unit_mmap_buf_free(nxt_unit_mmap_buf_t *mmap_buf);
83static void nxt_unit_free_outgoing_buf(nxt_unit_mmap_buf_t *mmap_buf);
84static nxt_unit_read_buf_t *nxt_unit_read_buf_get(nxt_unit_ctx_t *ctx);
85static nxt_unit_read_buf_t *nxt_unit_read_buf_get_impl(

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

114 nxt_port_mmap_header_t **hdr, nxt_unit_read_buf_t *rbuf);
115static int nxt_unit_mmap_read(nxt_unit_ctx_t *ctx,
116 nxt_unit_recv_msg_t *recv_msg, nxt_unit_read_buf_t *rbuf);
117static int nxt_unit_get_mmap(nxt_unit_ctx_t *ctx, pid_t pid, uint32_t id);
118static void nxt_unit_mmap_release(nxt_unit_ctx_t *ctx,
119 nxt_port_mmap_header_t *hdr, void *start, uint32_t size);
120static int nxt_unit_send_shm_ack(nxt_unit_ctx_t *ctx, pid_t pid);
121
79static nxt_unit_mmap_buf_t *nxt_unit_mmap_buf_get(nxt_unit_ctx_t *ctx);
80static void nxt_unit_mmap_buf_release(nxt_unit_mmap_buf_t *mmap_buf);
81static int nxt_unit_mmap_buf_send(nxt_unit_request_info_t *req,
82 nxt_unit_mmap_buf_t *mmap_buf, int last);
83static void nxt_unit_mmap_buf_free(nxt_unit_mmap_buf_t *mmap_buf);
84static void nxt_unit_free_outgoing_buf(nxt_unit_mmap_buf_t *mmap_buf);
85static nxt_unit_read_buf_t *nxt_unit_read_buf_get(nxt_unit_ctx_t *ctx);
86static nxt_unit_read_buf_t *nxt_unit_read_buf_get_impl(

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

115 nxt_port_mmap_header_t **hdr, nxt_unit_read_buf_t *rbuf);
116static int nxt_unit_mmap_read(nxt_unit_ctx_t *ctx,
117 nxt_unit_recv_msg_t *recv_msg, nxt_unit_read_buf_t *rbuf);
118static int nxt_unit_get_mmap(nxt_unit_ctx_t *ctx, pid_t pid, uint32_t id);
119static void nxt_unit_mmap_release(nxt_unit_ctx_t *ctx,
120 nxt_port_mmap_header_t *hdr, void *start, uint32_t size);
121static int nxt_unit_send_shm_ack(nxt_unit_ctx_t *ctx, pid_t pid);
122
122static nxt_unit_process_t *nxt_unit_process_get(nxt_unit_impl_t *lib,
123 pid_t pid);
123static nxt_unit_process_t *nxt_unit_process_get(nxt_unit_ctx_t *ctx, pid_t pid);
124static nxt_unit_process_t *nxt_unit_process_find(nxt_unit_impl_t *lib,
125 pid_t pid, int remove);
126static nxt_unit_process_t *nxt_unit_process_pop_first(nxt_unit_impl_t *lib);
127static int nxt_unit_run_once_impl(nxt_unit_ctx_t *ctx);
128static int nxt_unit_read_buf(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf);
129static int nxt_unit_process_pending_rbuf(nxt_unit_ctx_t *ctx);
130static void nxt_unit_process_ready_req(nxt_unit_ctx_t *ctx);
131nxt_inline int nxt_unit_is_read_queue(nxt_unit_read_buf_t *rbuf);

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

181static int nxt_unit_request_hash_add(nxt_unit_ctx_t *ctx,
182 nxt_unit_request_info_t *req);
183static nxt_unit_request_info_t *nxt_unit_request_hash_find(
184 nxt_unit_ctx_t *ctx, uint32_t stream, int remove);
185
186static char * nxt_unit_snprint_prefix(char *p, char *end, pid_t pid, int level);
187static void *nxt_unit_lvlhsh_alloc(void *data, size_t size);
188static void nxt_unit_lvlhsh_free(void *data, void *p);
124static nxt_unit_process_t *nxt_unit_process_find(nxt_unit_impl_t *lib,
125 pid_t pid, int remove);
126static nxt_unit_process_t *nxt_unit_process_pop_first(nxt_unit_impl_t *lib);
127static int nxt_unit_run_once_impl(nxt_unit_ctx_t *ctx);
128static int nxt_unit_read_buf(nxt_unit_ctx_t *ctx, nxt_unit_read_buf_t *rbuf);
129static int nxt_unit_process_pending_rbuf(nxt_unit_ctx_t *ctx);
130static void nxt_unit_process_ready_req(nxt_unit_ctx_t *ctx);
131nxt_inline int nxt_unit_is_read_queue(nxt_unit_read_buf_t *rbuf);

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

181static int nxt_unit_request_hash_add(nxt_unit_ctx_t *ctx,
182 nxt_unit_request_info_t *req);
183static nxt_unit_request_info_t *nxt_unit_request_hash_find(
184 nxt_unit_ctx_t *ctx, uint32_t stream, int remove);
185
186static char * nxt_unit_snprint_prefix(char *p, char *end, pid_t pid, int level);
187static void *nxt_unit_lvlhsh_alloc(void *data, size_t size);
188static void nxt_unit_lvlhsh_free(void *data, void *p);
189static void *nxt_unit_malloc(size_t size);
190static void nxt_unit_free(void *p);
191static int nxt_unit_memcasecmp(const void *p1, const void *p2, size_t length);
192
193
194struct nxt_unit_mmap_buf_s {
195 nxt_unit_buf_t buf;
196
197 nxt_unit_mmap_buf_t *next;
198 nxt_unit_mmap_buf_t **prev;

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

531
532static nxt_unit_impl_t *
533nxt_unit_create(nxt_unit_init_t *init)
534{
535 int rc;
536 nxt_unit_impl_t *lib;
537 nxt_unit_callbacks_t *cb;
538
189static int nxt_unit_memcasecmp(const void *p1, const void *p2, size_t length);
190
191
192struct nxt_unit_mmap_buf_s {
193 nxt_unit_buf_t buf;
194
195 nxt_unit_mmap_buf_t *next;
196 nxt_unit_mmap_buf_t **prev;

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

529
530static nxt_unit_impl_t *
531nxt_unit_create(nxt_unit_init_t *init)
532{
533 int rc;
534 nxt_unit_impl_t *lib;
535 nxt_unit_callbacks_t *cb;
536
539 lib = nxt_unit_malloc(sizeof(nxt_unit_impl_t) + init->request_data_size);
537 lib = nxt_unit_malloc(NULL,
538 sizeof(nxt_unit_impl_t) + init->request_data_size);
540 if (nxt_slow_path(lib == NULL)) {
541 nxt_unit_alert(NULL, "failed to allocate unit struct");
542
543 return NULL;
544 }
545
546 rc = pthread_mutex_init(&lib->mutex, NULL);
547 if (nxt_slow_path(rc != 0)) {

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

586
587 nxt_unit_mmaps_init(&lib->incoming);
588 nxt_unit_mmaps_init(&lib->outgoing);
589
590 return lib;
591
592fail:
593
539 if (nxt_slow_path(lib == NULL)) {
540 nxt_unit_alert(NULL, "failed to allocate unit struct");
541
542 return NULL;
543 }
544
545 rc = pthread_mutex_init(&lib->mutex, NULL);
546 if (nxt_slow_path(rc != 0)) {

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

585
586 nxt_unit_mmaps_init(&lib->incoming);
587 nxt_unit_mmaps_init(&lib->outgoing);
588
589 return lib;
590
591fail:
592
594 nxt_unit_free(lib);
593 nxt_unit_free(NULL, lib);
595
596 return NULL;
597}
598
599
600static int
601nxt_unit_ctx_init(nxt_unit_impl_t *lib, nxt_unit_ctx_impl_t *ctx_impl,
602 void *data)

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

710
711 if (nxt_fast_path(lib->shared_port != NULL)) {
712 nxt_unit_port_release(lib->shared_port);
713 }
714
715 nxt_unit_mmaps_destroy(&lib->incoming);
716 nxt_unit_mmaps_destroy(&lib->outgoing);
717
594
595 return NULL;
596}
597
598
599static int
600nxt_unit_ctx_init(nxt_unit_impl_t *lib, nxt_unit_ctx_impl_t *ctx_impl,
601 void *data)

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

709
710 if (nxt_fast_path(lib->shared_port != NULL)) {
711 nxt_unit_port_release(lib->shared_port);
712 }
713
714 nxt_unit_mmaps_destroy(&lib->incoming);
715 nxt_unit_mmaps_destroy(&lib->outgoing);
716
718 nxt_unit_free(lib);
717 nxt_unit_free(NULL, lib);
719 }
720}
721
722
723nxt_inline void
724nxt_unit_mmap_buf_insert(nxt_unit_mmap_buf_t **head,
725 nxt_unit_mmap_buf_t *mmap_buf)
726{

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

1388
1389 pthread_mutex_unlock(&lib->mutex);
1390
1391 nxt_atomic_fetch_add(&ctx_impl->wait_items, 1);
1392
1393 return NXT_UNIT_AGAIN;
1394 }
1395
718 }
719}
720
721
722nxt_inline void
723nxt_unit_mmap_buf_insert(nxt_unit_mmap_buf_t **head,
724 nxt_unit_mmap_buf_t *mmap_buf)
725{

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

1387
1388 pthread_mutex_unlock(&lib->mutex);
1389
1390 nxt_atomic_fetch_add(&ctx_impl->wait_items, 1);
1391
1392 return NXT_UNIT_AGAIN;
1393 }
1394
1396 port_impl = nxt_unit_malloc(sizeof(nxt_unit_port_impl_t));
1395 port_impl = nxt_unit_malloc(ctx, sizeof(nxt_unit_port_impl_t));
1397 if (nxt_slow_path(port_impl == NULL)) {
1398 nxt_unit_alert(ctx, "check_response_port: malloc(%d) failed",
1399 (int) sizeof(nxt_unit_port_impl_t));
1400
1401 pthread_mutex_unlock(&lib->mutex);
1402
1403 return NXT_UNIT_ERROR;
1404 }

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

1412
1413 res = nxt_unit_port_hash_add(&lib->ports, port);
1414 if (nxt_slow_path(res != NXT_UNIT_OK)) {
1415 nxt_unit_alert(ctx, "check_response_port: %d,%d hash_add failed",
1416 port->id.pid, port->id.id);
1417
1418 pthread_mutex_unlock(&lib->mutex);
1419
1396 if (nxt_slow_path(port_impl == NULL)) {
1397 nxt_unit_alert(ctx, "check_response_port: malloc(%d) failed",
1398 (int) sizeof(nxt_unit_port_impl_t));
1399
1400 pthread_mutex_unlock(&lib->mutex);
1401
1402 return NXT_UNIT_ERROR;
1403 }

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

1411
1412 res = nxt_unit_port_hash_add(&lib->ports, port);
1413 if (nxt_slow_path(res != NXT_UNIT_OK)) {
1414 nxt_unit_alert(ctx, "check_response_port: %d,%d hash_add failed",
1415 port->id.pid, port->id.id);
1416
1417 pthread_mutex_unlock(&lib->mutex);
1418
1420 nxt_unit_free(port);
1419 nxt_unit_free(ctx, port);
1421
1422 return NXT_UNIT_ERROR;
1423 }
1424
1425 process = nxt_unit_process_find(lib, port_id->pid, 0);
1426 if (nxt_slow_path(process == NULL)) {
1427 nxt_unit_alert(ctx, "check_response_port: process %d not found",
1428 port->id.pid);
1429
1430 nxt_unit_port_hash_find(&lib->ports, port_id, 1);
1431
1432 pthread_mutex_unlock(&lib->mutex);
1433
1420
1421 return NXT_UNIT_ERROR;
1422 }
1423
1424 process = nxt_unit_process_find(lib, port_id->pid, 0);
1425 if (nxt_slow_path(process == NULL)) {
1426 nxt_unit_alert(ctx, "check_response_port: process %d not found",
1427 port->id.pid);
1428
1429 nxt_unit_port_hash_find(&lib->ports, port_id, 1);
1430
1431 pthread_mutex_unlock(&lib->mutex);
1432
1434 nxt_unit_free(port);
1433 nxt_unit_free(ctx, port);
1435
1436 return NXT_UNIT_ERROR;
1437 }
1438
1439 nxt_queue_insert_tail(&process->ports, &port_impl->link);
1440
1441 port_impl->process = process;
1442 port_impl->queue = NULL;

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

1634
1635 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit);
1636
1637 pthread_mutex_lock(&ctx_impl->mutex);
1638
1639 if (nxt_queue_is_empty(&ctx_impl->free_req)) {
1640 pthread_mutex_unlock(&ctx_impl->mutex);
1641
1434
1435 return NXT_UNIT_ERROR;
1436 }
1437
1438 nxt_queue_insert_tail(&process->ports, &port_impl->link);
1439
1440 port_impl->process = process;
1441 port_impl->queue = NULL;

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

1633
1634 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit);
1635
1636 pthread_mutex_lock(&ctx_impl->mutex);
1637
1638 if (nxt_queue_is_empty(&ctx_impl->free_req)) {
1639 pthread_mutex_unlock(&ctx_impl->mutex);
1640
1642 req_impl = nxt_unit_malloc(sizeof(nxt_unit_request_info_impl_t)
1643 + lib->request_data_size);
1641 req_impl = nxt_unit_malloc(ctx, sizeof(nxt_unit_request_info_impl_t)
1642 + lib->request_data_size);
1644 if (nxt_slow_path(req_impl == NULL)) {
1645 return NULL;
1646 }
1647
1648 req_impl->req.unit = ctx->unit;
1649 req_impl->req.ctx = ctx;
1650
1651 pthread_mutex_lock(&ctx_impl->mutex);

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

1722{
1723 nxt_unit_ctx_impl_t *ctx_impl;
1724
1725 ctx_impl = nxt_container_of(req_impl->req.ctx, nxt_unit_ctx_impl_t, ctx);
1726
1727 nxt_queue_remove(&req_impl->link);
1728
1729 if (req_impl != &ctx_impl->req) {
1643 if (nxt_slow_path(req_impl == NULL)) {
1644 return NULL;
1645 }
1646
1647 req_impl->req.unit = ctx->unit;
1648 req_impl->req.ctx = ctx;
1649
1650 pthread_mutex_lock(&ctx_impl->mutex);

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

1721{
1722 nxt_unit_ctx_impl_t *ctx_impl;
1723
1724 ctx_impl = nxt_container_of(req_impl->req.ctx, nxt_unit_ctx_impl_t, ctx);
1725
1726 nxt_queue_remove(&req_impl->link);
1727
1728 if (req_impl != &ctx_impl->req) {
1730 nxt_unit_free(req_impl);
1729 nxt_unit_free(&ctx_impl->ctx, req_impl);
1731 }
1732}
1733
1734
1735static nxt_unit_websocket_frame_impl_t *
1736nxt_unit_websocket_frame_get(nxt_unit_ctx_t *ctx)
1737{
1738 nxt_queue_link_t *lnk;
1739 nxt_unit_ctx_impl_t *ctx_impl;
1740 nxt_unit_websocket_frame_impl_t *ws_impl;
1741
1742 ctx_impl = nxt_container_of(ctx, nxt_unit_ctx_impl_t, ctx);
1743
1744 pthread_mutex_lock(&ctx_impl->mutex);
1745
1746 if (nxt_queue_is_empty(&ctx_impl->free_ws)) {
1747 pthread_mutex_unlock(&ctx_impl->mutex);
1748
1730 }
1731}
1732
1733
1734static nxt_unit_websocket_frame_impl_t *
1735nxt_unit_websocket_frame_get(nxt_unit_ctx_t *ctx)
1736{
1737 nxt_queue_link_t *lnk;
1738 nxt_unit_ctx_impl_t *ctx_impl;
1739 nxt_unit_websocket_frame_impl_t *ws_impl;
1740
1741 ctx_impl = nxt_container_of(ctx, nxt_unit_ctx_impl_t, ctx);
1742
1743 pthread_mutex_lock(&ctx_impl->mutex);
1744
1745 if (nxt_queue_is_empty(&ctx_impl->free_ws)) {
1746 pthread_mutex_unlock(&ctx_impl->mutex);
1747
1749 ws_impl = nxt_unit_malloc(sizeof(nxt_unit_websocket_frame_impl_t));
1748 ws_impl = nxt_unit_malloc(ctx, sizeof(nxt_unit_websocket_frame_impl_t));
1750 if (nxt_slow_path(ws_impl == NULL)) {
1751 return NULL;
1752 }
1753
1754 } else {
1755 lnk = nxt_queue_first(&ctx_impl->free_ws);
1756 nxt_queue_remove(lnk);
1757

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

1783
1784 nxt_queue_insert_tail(&ws_impl->ctx_impl->free_ws, &ws_impl->link);
1785
1786 pthread_mutex_unlock(&ws_impl->ctx_impl->mutex);
1787}
1788
1789
1790static void
1749 if (nxt_slow_path(ws_impl == NULL)) {
1750 return NULL;
1751 }
1752
1753 } else {
1754 lnk = nxt_queue_first(&ctx_impl->free_ws);
1755 nxt_queue_remove(lnk);
1756

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

1782
1783 nxt_queue_insert_tail(&ws_impl->ctx_impl->free_ws, &ws_impl->link);
1784
1785 pthread_mutex_unlock(&ws_impl->ctx_impl->mutex);
1786}
1787
1788
1789static void
1791nxt_unit_websocket_frame_free(nxt_unit_websocket_frame_impl_t *ws_impl)
1790nxt_unit_websocket_frame_free(nxt_unit_ctx_t *ctx,
1791 nxt_unit_websocket_frame_impl_t *ws_impl)
1792{
1793 nxt_queue_remove(&ws_impl->link);
1794
1792{
1793 nxt_queue_remove(&ws_impl->link);
1794
1795 nxt_unit_free(ws_impl);
1795 nxt_unit_free(ctx, ws_impl);
1796}
1797
1798
1799uint16_t
1800nxt_unit_field_hash(const char *name, size_t name_length)
1801{
1802 u_char ch;
1803 uint32_t hash;

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

2324
2325 ctx_impl = nxt_container_of(ctx, nxt_unit_ctx_impl_t, ctx);
2326
2327 pthread_mutex_lock(&ctx_impl->mutex);
2328
2329 if (ctx_impl->free_buf == NULL) {
2330 pthread_mutex_unlock(&ctx_impl->mutex);
2331
1796}
1797
1798
1799uint16_t
1800nxt_unit_field_hash(const char *name, size_t name_length)
1801{
1802 u_char ch;
1803 uint32_t hash;

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

2324
2325 ctx_impl = nxt_container_of(ctx, nxt_unit_ctx_impl_t, ctx);
2326
2327 pthread_mutex_lock(&ctx_impl->mutex);
2328
2329 if (ctx_impl->free_buf == NULL) {
2330 pthread_mutex_unlock(&ctx_impl->mutex);
2331
2332 mmap_buf = nxt_unit_malloc(sizeof(nxt_unit_mmap_buf_t));
2332 mmap_buf = nxt_unit_malloc(ctx, sizeof(nxt_unit_mmap_buf_t));
2333 if (nxt_slow_path(mmap_buf == NULL)) {
2334 return NULL;
2335 }
2336
2337 } else {
2338 mmap_buf = ctx_impl->free_buf;
2339
2340 nxt_unit_mmap_buf_unlink(mmap_buf);

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

2642 mmap_buf->buf.end - mmap_buf->buf.start);
2643
2644 mmap_buf->hdr = NULL;
2645
2646 return;
2647 }
2648
2649 if (mmap_buf->free_ptr != NULL) {
2333 if (nxt_slow_path(mmap_buf == NULL)) {
2334 return NULL;
2335 }
2336
2337 } else {
2338 mmap_buf = ctx_impl->free_buf;
2339
2340 nxt_unit_mmap_buf_unlink(mmap_buf);

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

2642 mmap_buf->buf.end - mmap_buf->buf.start);
2643
2644 mmap_buf->hdr = NULL;
2645
2646 return;
2647 }
2648
2649 if (mmap_buf->free_ptr != NULL) {
2650 nxt_unit_free(mmap_buf->free_ptr);
2650 nxt_unit_free(&mmap_buf->ctx_impl->ctx, mmap_buf->free_ptr);
2651
2652 mmap_buf->free_ptr = NULL;
2653 }
2654}
2655
2656
2657static nxt_unit_read_buf_t *
2658nxt_unit_read_buf_get(nxt_unit_ctx_t *ctx)

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

2684 link = nxt_queue_first(&ctx_impl->free_rbuf);
2685 nxt_queue_remove(link);
2686
2687 rbuf = nxt_container_of(link, nxt_unit_read_buf_t, link);
2688
2689 return rbuf;
2690 }
2691
2651
2652 mmap_buf->free_ptr = NULL;
2653 }
2654}
2655
2656
2657static nxt_unit_read_buf_t *
2658nxt_unit_read_buf_get(nxt_unit_ctx_t *ctx)

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

2684 link = nxt_queue_first(&ctx_impl->free_rbuf);
2685 nxt_queue_remove(link);
2686
2687 rbuf = nxt_container_of(link, nxt_unit_read_buf_t, link);
2688
2689 return rbuf;
2690 }
2691
2692 rbuf = nxt_unit_malloc(sizeof(nxt_unit_read_buf_t));
2692 rbuf = nxt_unit_malloc(&ctx_impl->ctx, sizeof(nxt_unit_read_buf_t));
2693
2694 if (nxt_fast_path(rbuf != NULL)) {
2695 rbuf->ctx_impl = ctx_impl;
2696 }
2697
2698 return rbuf;
2699}
2700

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

3043 }
3044
3045 mmap_buf = nxt_unit_mmap_buf_get(req->ctx);
3046 if (nxt_slow_path(mmap_buf == NULL)) {
3047 nxt_unit_req_alert(req, "preread: failed to allocate buf");
3048 return NULL;
3049 }
3050
2693
2694 if (nxt_fast_path(rbuf != NULL)) {
2695 rbuf->ctx_impl = ctx_impl;
2696 }
2697
2698 return rbuf;
2699}
2700

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

3043 }
3044
3045 mmap_buf = nxt_unit_mmap_buf_get(req->ctx);
3046 if (nxt_slow_path(mmap_buf == NULL)) {
3047 nxt_unit_req_alert(req, "preread: failed to allocate buf");
3048 return NULL;
3049 }
3050
3051 mmap_buf->free_ptr = nxt_unit_malloc(size);
3051 mmap_buf->free_ptr = nxt_unit_malloc(req->ctx, size);
3052 if (nxt_slow_path(mmap_buf->free_ptr == NULL)) {
3053 nxt_unit_req_alert(req, "preread: failed to allocate buf memory");
3054 nxt_unit_mmap_buf_release(mmap_buf);
3055 return NULL;
3056 }
3057
3058 mmap_buf->plain_ptr = mmap_buf->free_ptr;
3059

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

3326 ws_impl = nxt_container_of(ws, nxt_unit_websocket_frame_impl_t, ws);
3327
3328 if (ws_impl->buf->free_ptr != NULL || ws_impl->buf->hdr != NULL) {
3329 return NXT_UNIT_OK;
3330 }
3331
3332 size = ws_impl->buf->buf.end - ws_impl->buf->buf.start;
3333
3052 if (nxt_slow_path(mmap_buf->free_ptr == NULL)) {
3053 nxt_unit_req_alert(req, "preread: failed to allocate buf memory");
3054 nxt_unit_mmap_buf_release(mmap_buf);
3055 return NULL;
3056 }
3057
3058 mmap_buf->plain_ptr = mmap_buf->free_ptr;
3059

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

3326 ws_impl = nxt_container_of(ws, nxt_unit_websocket_frame_impl_t, ws);
3327
3328 if (ws_impl->buf->free_ptr != NULL || ws_impl->buf->hdr != NULL) {
3329 return NXT_UNIT_OK;
3330 }
3331
3332 size = ws_impl->buf->buf.end - ws_impl->buf->buf.start;
3333
3334 b = nxt_unit_malloc(size);
3334 b = nxt_unit_malloc(ws->req->ctx, size);
3335 if (nxt_slow_path(b == NULL)) {
3336 return NXT_UNIT_ERROR;
3337 }
3338
3339 memcpy(b, ws_impl->buf->buf.start, size);
3340
3341 hsize = nxt_websocket_frame_header_size(b);
3342

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

3834 nxt_port_mmap_header_t *hdr;
3835
3836 if (size <= NXT_UNIT_MAX_PLAIN_SIZE) {
3837 if (local_buf != NULL) {
3838 mmap_buf->free_ptr = NULL;
3839 mmap_buf->plain_ptr = local_buf;
3840
3841 } else {
3335 if (nxt_slow_path(b == NULL)) {
3336 return NXT_UNIT_ERROR;
3337 }
3338
3339 memcpy(b, ws_impl->buf->buf.start, size);
3340
3341 hsize = nxt_websocket_frame_header_size(b);
3342

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

3834 nxt_port_mmap_header_t *hdr;
3835
3836 if (size <= NXT_UNIT_MAX_PLAIN_SIZE) {
3837 if (local_buf != NULL) {
3838 mmap_buf->free_ptr = NULL;
3839 mmap_buf->plain_ptr = local_buf;
3840
3841 } else {
3842 mmap_buf->free_ptr = nxt_unit_malloc(size + sizeof(nxt_port_msg_t));
3842 mmap_buf->free_ptr = nxt_unit_malloc(ctx,
3843 size + sizeof(nxt_port_msg_t));
3843 if (nxt_slow_path(mmap_buf->free_ptr == NULL)) {
3844 return NXT_UNIT_ERROR;
3845 }
3846
3847 mmap_buf->plain_ptr = mmap_buf->free_ptr;
3848 }
3849
3850 mmap_buf->hdr = NULL;

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

4004{
4005 long c;
4006
4007 c = nxt_atomic_fetch_add(&process->use_count, -1);
4008
4009 if (c == 1) {
4010 nxt_unit_debug(NULL, "destroy process #%d", (int) process->pid);
4011
3844 if (nxt_slow_path(mmap_buf->free_ptr == NULL)) {
3845 return NXT_UNIT_ERROR;
3846 }
3847
3848 mmap_buf->plain_ptr = mmap_buf->free_ptr;
3849 }
3850
3851 mmap_buf->hdr = NULL;

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

4005{
4006 long c;
4007
4008 c = nxt_atomic_fetch_add(&process->use_count, -1);
4009
4010 if (c == 1) {
4011 nxt_unit_debug(NULL, "destroy process #%d", (int) process->pid);
4012
4012 nxt_unit_free(process);
4013 nxt_unit_free(NULL, process);
4013 }
4014}
4015
4016
4017static void
4018nxt_unit_mmaps_destroy(nxt_unit_mmaps_t *mmaps)
4019{
4020 nxt_unit_mmap_t *mm, *end;
4021
4022 if (mmaps->elts != NULL) {
4023 end = mmaps->elts + mmaps->size;
4024
4025 for (mm = mmaps->elts; mm < end; mm++) {
4026 munmap(mm->hdr, PORT_MMAP_SIZE);
4027 }
4028
4014 }
4015}
4016
4017
4018static void
4019nxt_unit_mmaps_destroy(nxt_unit_mmaps_t *mmaps)
4020{
4021 nxt_unit_mmap_t *mm, *end;
4022
4023 if (mmaps->elts != NULL) {
4024 end = mmaps->elts + mmaps->size;
4025
4026 for (mm = mmaps->elts; mm < end; mm++) {
4027 munmap(mm->hdr, PORT_MMAP_SIZE);
4028 }
4029
4029 nxt_unit_free(mmaps->elts);
4030 nxt_unit_free(NULL, mmaps->elts);
4030 }
4031
4032 pthread_mutex_destroy(&mmaps->mutex);
4033}
4034
4035
4036static int
4037nxt_unit_check_rbuf_mmap(nxt_unit_ctx_t *ctx, nxt_unit_mmaps_t *mmaps,

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

4309 lhq->key_hash = nxt_murmur_hash2(pid, sizeof(*pid));
4310 lhq->key.length = sizeof(*pid);
4311 lhq->key.start = (u_char *) pid;
4312 lhq->proto = &lvlhsh_processes_proto;
4313}
4314
4315
4316static nxt_unit_process_t *
4031 }
4032
4033 pthread_mutex_destroy(&mmaps->mutex);
4034}
4035
4036
4037static int
4038nxt_unit_check_rbuf_mmap(nxt_unit_ctx_t *ctx, nxt_unit_mmaps_t *mmaps,

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

4310 lhq->key_hash = nxt_murmur_hash2(pid, sizeof(*pid));
4311 lhq->key.length = sizeof(*pid);
4312 lhq->key.start = (u_char *) pid;
4313 lhq->proto = &lvlhsh_processes_proto;
4314}
4315
4316
4317static nxt_unit_process_t *
4317nxt_unit_process_get(nxt_unit_impl_t *lib, pid_t pid)
4318nxt_unit_process_get(nxt_unit_ctx_t *ctx, pid_t pid)
4318{
4319{
4320 nxt_unit_impl_t *lib;
4319 nxt_unit_process_t *process;
4320 nxt_lvlhsh_query_t lhq;
4321
4321 nxt_unit_process_t *process;
4322 nxt_lvlhsh_query_t lhq;
4323
4324 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit);
4325
4322 nxt_unit_process_lhq_pid(&lhq, &pid);
4323
4324 if (nxt_lvlhsh_find(&lib->processes, &lhq) == NXT_OK) {
4325 process = lhq.value;
4326 nxt_unit_process_use(process);
4327
4328 return process;
4329 }
4330
4326 nxt_unit_process_lhq_pid(&lhq, &pid);
4327
4328 if (nxt_lvlhsh_find(&lib->processes, &lhq) == NXT_OK) {
4329 process = lhq.value;
4330 nxt_unit_process_use(process);
4331
4332 return process;
4333 }
4334
4331 process = nxt_unit_malloc(sizeof(nxt_unit_process_t));
4335 process = nxt_unit_malloc(ctx, sizeof(nxt_unit_process_t));
4332 if (nxt_slow_path(process == NULL)) {
4336 if (nxt_slow_path(process == NULL)) {
4333 nxt_unit_alert(NULL, "failed to allocate process for #%d", (int) pid);
4337 nxt_unit_alert(ctx, "failed to allocate process for #%d", (int) pid);
4334
4335 return NULL;
4336 }
4337
4338 process->pid = pid;
4339 process->use_count = 2;
4340 process->next_port_id = 0;
4341 process->lib = lib;

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

4346 lhq.value = process;
4347
4348 switch (nxt_lvlhsh_insert(&lib->processes, &lhq)) {
4349
4350 case NXT_OK:
4351 break;
4352
4353 default:
4338
4339 return NULL;
4340 }
4341
4342 process->pid = pid;
4343 process->use_count = 2;
4344 process->next_port_id = 0;
4345 process->lib = lib;

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

4350 lhq.value = process;
4351
4352 switch (nxt_lvlhsh_insert(&lib->processes, &lhq)) {
4353
4354 case NXT_OK:
4355 break;
4356
4357 default:
4354 nxt_unit_alert(NULL, "process %d insert failed", (int) pid);
4358 nxt_unit_alert(ctx, "process %d insert failed", (int) pid);
4355
4359
4356 nxt_unit_free(process);
4360 nxt_unit_free(ctx, process);
4357 process = NULL;
4358 break;
4359 }
4360
4361 return process;
4362}
4363
4364

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

4919 void *mem;
4920 nxt_unit_impl_t *lib;
4921 nxt_unit_port_t *port;
4922 nxt_unit_ctx_impl_t *new_ctx;
4923 nxt_unit_port_impl_t *port_impl;
4924
4925 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit);
4926
4361 process = NULL;
4362 break;
4363 }
4364
4365 return process;
4366}
4367
4368

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

4923 void *mem;
4924 nxt_unit_impl_t *lib;
4925 nxt_unit_port_t *port;
4926 nxt_unit_ctx_impl_t *new_ctx;
4927 nxt_unit_port_impl_t *port_impl;
4928
4929 lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit);
4930
4927 new_ctx = nxt_unit_malloc(sizeof(nxt_unit_ctx_impl_t)
4928 + lib->request_data_size);
4931 new_ctx = nxt_unit_malloc(ctx, sizeof(nxt_unit_ctx_impl_t)
4932 + lib->request_data_size);
4929 if (nxt_slow_path(new_ctx == NULL)) {
4930 nxt_unit_alert(ctx, "failed to allocate context");
4931
4932 return NULL;
4933 }
4934
4935 rc = nxt_unit_ctx_init(lib, new_ctx, data);
4936 if (nxt_slow_path(rc != NXT_UNIT_OK)) {
4933 if (nxt_slow_path(new_ctx == NULL)) {
4934 nxt_unit_alert(ctx, "failed to allocate context");
4935
4936 return NULL;
4937 }
4938
4939 rc = nxt_unit_ctx_init(lib, new_ctx, data);
4940 if (nxt_slow_path(rc != NXT_UNIT_OK)) {
4937 nxt_unit_free(new_ctx);
4941 nxt_unit_free(ctx, new_ctx);
4938
4939 return NULL;
4940 }
4941
4942 queue_fd = -1;
4943
4944 port = nxt_unit_create_port(ctx);
4945 if (nxt_slow_path(port == NULL)) {

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

5008 } nxt_queue_loop;
5009
5010 nxt_unit_mmap_buf_unlink(&ctx_impl->ctx_buf[0]);
5011 nxt_unit_mmap_buf_unlink(&ctx_impl->ctx_buf[1]);
5012
5013 while (ctx_impl->free_buf != NULL) {
5014 mmap_buf = ctx_impl->free_buf;
5015 nxt_unit_mmap_buf_unlink(mmap_buf);
4942
4943 return NULL;
4944 }
4945
4946 queue_fd = -1;
4947
4948 port = nxt_unit_create_port(ctx);
4949 if (nxt_slow_path(port == NULL)) {

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

5012 } nxt_queue_loop;
5013
5014 nxt_unit_mmap_buf_unlink(&ctx_impl->ctx_buf[0]);
5015 nxt_unit_mmap_buf_unlink(&ctx_impl->ctx_buf[1]);
5016
5017 while (ctx_impl->free_buf != NULL) {
5018 mmap_buf = ctx_impl->free_buf;
5019 nxt_unit_mmap_buf_unlink(mmap_buf);
5016 nxt_unit_free(mmap_buf);
5020 nxt_unit_free(&ctx_impl->ctx, mmap_buf);
5017 }
5018
5019 nxt_queue_each(req_impl, &ctx_impl->free_req,
5020 nxt_unit_request_info_impl_t, link)
5021 {
5022 nxt_unit_request_info_free(req_impl);
5023
5024 } nxt_queue_loop;
5025
5026 nxt_queue_each(ws_impl, &ctx_impl->free_ws,
5027 nxt_unit_websocket_frame_impl_t, link)
5028 {
5021 }
5022
5023 nxt_queue_each(req_impl, &ctx_impl->free_req,
5024 nxt_unit_request_info_impl_t, link)
5025 {
5026 nxt_unit_request_info_free(req_impl);
5027
5028 } nxt_queue_loop;
5029
5030 nxt_queue_each(ws_impl, &ctx_impl->free_ws,
5031 nxt_unit_websocket_frame_impl_t, link)
5032 {
5029 nxt_unit_websocket_frame_free(ws_impl);
5033 nxt_unit_websocket_frame_free(&ctx_impl->ctx, ws_impl);
5030
5031 } nxt_queue_loop;
5032
5033 pthread_mutex_destroy(&ctx_impl->mutex);
5034
5035 nxt_queue_remove(&ctx_impl->link);
5036
5037 if (nxt_fast_path(ctx_impl->read_port != NULL)) {
5038 nxt_unit_remove_port(lib, &ctx_impl->read_port->id);
5039 nxt_unit_port_release(ctx_impl->read_port);
5040 }
5041
5042 if (ctx_impl != &lib->main_ctx) {
5034
5035 } nxt_queue_loop;
5036
5037 pthread_mutex_destroy(&ctx_impl->mutex);
5038
5039 nxt_queue_remove(&ctx_impl->link);
5040
5041 if (nxt_fast_path(ctx_impl->read_port != NULL)) {
5042 nxt_unit_remove_port(lib, &ctx_impl->read_port->id);
5043 nxt_unit_port_release(ctx_impl->read_port);
5044 }
5045
5046 if (ctx_impl != &lib->main_ctx) {
5043 nxt_unit_free(ctx_impl);
5047 nxt_unit_free(&lib->main_ctx.ctx, ctx_impl);
5044 }
5045
5046 nxt_unit_lib_release(lib);
5047}
5048
5049
5050/* SOCK_SEQPACKET is disabled to test SOCK_DGRAM on all platforms. */
5051#if (0 || NXT_HAVE_AF_UNIX_SOCK_SEQPACKET)

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

5087 return NULL;
5088 }
5089
5090 nxt_unit_debug(ctx, "create_port: new socketpair: %d->%d",
5091 port_sockets[0], port_sockets[1]);
5092
5093 pthread_mutex_lock(&lib->mutex);
5094
5048 }
5049
5050 nxt_unit_lib_release(lib);
5051}
5052
5053
5054/* SOCK_SEQPACKET is disabled to test SOCK_DGRAM on all platforms. */
5055#if (0 || NXT_HAVE_AF_UNIX_SOCK_SEQPACKET)

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

5091 return NULL;
5092 }
5093
5094 nxt_unit_debug(ctx, "create_port: new socketpair: %d->%d",
5095 port_sockets[0], port_sockets[1]);
5096
5097 pthread_mutex_lock(&lib->mutex);
5098
5095 process = nxt_unit_process_get(lib, lib->pid);
5099 process = nxt_unit_process_get(ctx, lib->pid);
5096 if (nxt_slow_path(process == NULL)) {
5097 pthread_mutex_unlock(&lib->mutex);
5098
5099 nxt_unit_close(port_sockets[0]);
5100 nxt_unit_close(port_sockets[1]);
5101
5102 return NULL;
5103 }

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

5220 }
5221
5222 if (port_impl->queue != NULL) {
5223 munmap(port_impl->queue, (port->id.id == (nxt_port_id_t) -1)
5224 ? sizeof(nxt_app_queue_t)
5225 : sizeof(nxt_port_queue_t));
5226 }
5227
5100 if (nxt_slow_path(process == NULL)) {
5101 pthread_mutex_unlock(&lib->mutex);
5102
5103 nxt_unit_close(port_sockets[0]);
5104 nxt_unit_close(port_sockets[1]);
5105
5106 return NULL;
5107 }

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

5224 }
5225
5226 if (port_impl->queue != NULL) {
5227 munmap(port_impl->queue, (port->id.id == (nxt_port_id_t) -1)
5228 ? sizeof(nxt_app_queue_t)
5229 : sizeof(nxt_port_queue_t));
5230 }
5231
5228 nxt_unit_free(port_impl);
5232 nxt_unit_free(NULL, port_impl);
5229 }
5230}
5231
5232
5233static nxt_unit_port_t *
5234nxt_unit_add_port(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port, void *queue)
5235{
5236 int rc;

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

5327 }
5328
5329 new_port = NULL;
5330
5331 nxt_unit_debug(ctx, "add_port: port{%d,%d} in_fd %d out_fd %d queue %p",
5332 port->id.pid, port->id.id,
5333 port->in_fd, port->out_fd, queue);
5334
5233 }
5234}
5235
5236
5237static nxt_unit_port_t *
5238nxt_unit_add_port(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port, void *queue)
5239{
5240 int rc;

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

5331 }
5332
5333 new_port = NULL;
5334
5335 nxt_unit_debug(ctx, "add_port: port{%d,%d} in_fd %d out_fd %d queue %p",
5336 port->id.pid, port->id.id,
5337 port->in_fd, port->out_fd, queue);
5338
5335 process = nxt_unit_process_get(lib, port->id.pid);
5339 process = nxt_unit_process_get(ctx, port->id.pid);
5336 if (nxt_slow_path(process == NULL)) {
5337 goto unlock;
5338 }
5339
5340 if (port->id.id >= process->next_port_id) {
5341 process->next_port_id = port->id.id + 1;
5342 }
5343
5340 if (nxt_slow_path(process == NULL)) {
5341 goto unlock;
5342 }
5343
5344 if (port->id.id >= process->next_port_id) {
5345 process->next_port_id = port->id.id + 1;
5346 }
5347
5344 new_port = nxt_unit_malloc(sizeof(nxt_unit_port_impl_t));
5348 new_port = nxt_unit_malloc(ctx, sizeof(nxt_unit_port_impl_t));
5345 if (nxt_slow_path(new_port == NULL)) {
5346 nxt_unit_alert(ctx, "add_port: %d,%d malloc() failed",
5347 port->id.pid, port->id.id);
5348
5349 goto unlock;
5350 }
5351
5352 new_port->port = *port;
5353
5354 rc = nxt_unit_port_hash_add(&lib->ports, &new_port->port);
5355 if (nxt_slow_path(rc != NXT_UNIT_OK)) {
5356 nxt_unit_alert(ctx, "add_port: %d,%d hash_add failed",
5357 port->id.pid, port->id.id);
5358
5349 if (nxt_slow_path(new_port == NULL)) {
5350 nxt_unit_alert(ctx, "add_port: %d,%d malloc() failed",
5351 port->id.pid, port->id.id);
5352
5353 goto unlock;
5354 }
5355
5356 new_port->port = *port;
5357
5358 rc = nxt_unit_port_hash_add(&lib->ports, &new_port->port);
5359 if (nxt_slow_path(rc != NXT_UNIT_OK)) {
5360 nxt_unit_alert(ctx, "add_port: %d,%d hash_add failed",
5361 port->id.pid, port->id.id);
5362
5359 nxt_unit_free(new_port);
5363 nxt_unit_free(ctx, new_port);
5360
5361 new_port = NULL;
5362
5363 goto unlock;
5364 }
5365
5366 nxt_queue_insert_tail(&process->ports, &new_port->link);
5367

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

6371 (int) size, (int) size, strerror(err), err);
6372 return NULL;
6373}
6374
6375
6376static void
6377nxt_unit_lvlhsh_free(void *data, void *p)
6378{
5364
5365 new_port = NULL;
5366
5367 goto unlock;
5368 }
5369
5370 nxt_queue_insert_tail(&process->ports, &new_port->link);
5371

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

6375 (int) size, (int) size, strerror(err), err);
6376 return NULL;
6377}
6378
6379
6380static void
6381nxt_unit_lvlhsh_free(void *data, void *p)
6382{
6379 nxt_unit_free(p);
6383 nxt_unit_free(NULL, p);
6380}
6381
6382
6384}
6385
6386
6383static void *
6384nxt_unit_malloc(size_t size)
6387void *
6388nxt_unit_malloc(nxt_unit_ctx_t *ctx, size_t size)
6385{
6386 void *p;
6387
6388 p = malloc(size);
6389
6390 if (nxt_fast_path(p != NULL)) {
6389{
6390 void *p;
6391
6392 p = malloc(size);
6393
6394 if (nxt_fast_path(p != NULL)) {
6391 nxt_unit_debug(NULL, "malloc(%d): %p", (int) size, p);
6395 nxt_unit_debug(ctx, "malloc(%d): %p", (int) size, p);
6392
6393 } else {
6396
6397 } else {
6394 nxt_unit_alert(NULL, "malloc(%d) failed: %s (%d)",
6398 nxt_unit_alert(ctx, "malloc(%d) failed: %s (%d)",
6395 (int) size, strerror(errno), errno);
6396 }
6397
6398 return p;
6399}
6400
6401
6399 (int) size, strerror(errno), errno);
6400 }
6401
6402 return p;
6403}
6404
6405
6402static void
6403nxt_unit_free(void *p)
6406void
6407nxt_unit_free(nxt_unit_ctx_t *ctx, void *p)
6404{
6408{
6405 nxt_unit_debug(NULL, "free(%p)", p);
6409 nxt_unit_debug(ctx, "free(%p)", p);
6406
6407 free(p);
6408}
6409
6410
6411static int
6412nxt_unit_memcasecmp(const void *p1, const void *p2, size_t length)
6413{

--- 23 unchanged lines hidden ---
6410
6411 free(p);
6412}
6413
6414
6415static int
6416nxt_unit_memcasecmp(const void *p1, const void *p2, size_t length)
6417{

--- 23 unchanged lines hidden ---