nxt_event_engine.c (337:854a1a440616) nxt_event_engine.c (358:40bbd4c2349d)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

551 now = nxt_thread_monotonic_time(thr) / 1000000;
552
553 nxt_timer_expire(engine, now);
554 }
555}
556
557
558void *
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

551 now = nxt_thread_monotonic_time(thr) / 1000000;
552
553 nxt_timer_expire(engine, now);
554 }
555}
556
557
558void *
559nxt_event_engine_mem_alloc(nxt_event_engine_t *engine, uint32_t *slot,
559nxt_event_engine_mem_alloc(nxt_event_engine_t *engine, uint8_t *slot,
560 size_t size)
561{
560 size_t size)
561{
562 uint32_t n;
562 uint8_t n;
563 nxt_uint_t items;
564 nxt_array_t *mem_cache;
565 nxt_mem_cache_t *cache;
566 nxt_mem_cache_block_t *block;
567
568 mem_cache = engine->mem_cache;
569 n = *slot;
570
563 nxt_uint_t items;
564 nxt_array_t *mem_cache;
565 nxt_mem_cache_t *cache;
566 nxt_mem_cache_block_t *block;
567
568 mem_cache = engine->mem_cache;
569 n = *slot;
570
571 if (n == (uint32_t) -1) {
571 if (n == (uint8_t) -1) {
572
573 if (mem_cache == NULL) {
574 /* IPv4 nxt_sockaddr_t and HTTP/1 and HTTP/2 buffers. */
575 items = 3;
576#if (NXT_INET6)
577 items++;
578#endif
579#if (NXT_HAVE_UNIX_DOMAIN)

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

613 cache = mem_cache->elts;
614 cache = cache + n;
615
616 block = cache->free;
617
618 if (block != NULL) {
619 cache->free = block->next;
620 cache->count--;
572
573 if (mem_cache == NULL) {
574 /* IPv4 nxt_sockaddr_t and HTTP/1 and HTTP/2 buffers. */
575 items = 3;
576#if (NXT_INET6)
577 items++;
578#endif
579#if (NXT_HAVE_UNIX_DOMAIN)

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

613 cache = mem_cache->elts;
614 cache = cache + n;
615
616 block = cache->free;
617
618 if (block != NULL) {
619 cache->free = block->next;
620 cache->count--;
621
622 return block;
623 }
624
625 return nxt_mp_alloc(engine->mem_pool, size);
626}
627
628
629void
621 return block;
622 }
623
624 return nxt_mp_alloc(engine->mem_pool, size);
625}
626
627
628void
630nxt_event_engine_mem_free(nxt_event_engine_t *engine, uint32_t *slot, void *p)
629nxt_event_engine_mem_free(nxt_event_engine_t *engine, uint8_t *slot, void *p)
631{
632 nxt_mem_cache_t *cache;
633 nxt_mem_cache_block_t *block;
634
635 block = p;
636
637 cache = engine->mem_cache->elts;
638 cache = cache + *slot;

--- 28 unchanged lines hidden ---
630{
631 nxt_mem_cache_t *cache;
632 nxt_mem_cache_block_t *block;
633
634 block = p;
635
636 cache = engine->mem_cache->elts;
637 cache = cache + *slot;

--- 28 unchanged lines hidden ---