From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
tarantool-patches@dev.tarantool.org, gorcunov@gmail.com
Subject: Re: [Tarantool-patches] [PATCH 06/16] cord_buf: introduce ownership management
Date: Tue, 23 Mar 2021 10:46:05 +0300 [thread overview]
Message-ID: <4c4aa232-351b-e0b6-d38a-66d0e51b846e@tarantool.org> (raw)
In-Reply-To: <f952cd01-a60a-d77e-f3b8-4081ef3a3b4e@tarantool.org>
23.03.2021 01:32, Vladislav Shpilevoy пишет:
> Hi! Thanks for the review!
>
>>> diff --git a/src/lib/core/cord_buf.c b/src/lib/core/cord_buf.c
>>> index cac508c3d..9450d75bc 100644
>>> --- a/src/lib/core/cord_buf.c
>>> +++ b/src/lib/core/cord_buf.c
>>> @@ -5,6 +5,7 @@
>>> */
>>> #include "cord_buf.h"
>>> #include "fiber.h"
>>> +#include "trigger.h"
>>> #include "small/ibuf.h"
>>> @@ -13,35 +14,154 @@ enum {
>>> CORD_IBUF_START_CAPACITY = 16384,
>>> };
>>> -static struct ibuf *cord_buf_global = NULL;
>>> +/** Global buffer with automatic collection on fiber yield. */
>>> +struct cord_buf {
>>> + /** Base buffer. */
>>> + struct ibuf base;
>>> + /**
>>> + * Triggers on fiber stop/yield when the buffer is either destroyed or
>>> + * cached to the global stash for later reuse.
>>> + */
>>> + struct trigger on_stop;
>>> + struct trigger on_yield;
>>> +#if !NDEBUG
>> Shouldn't it be `#if !defined(NDEBUG)`? I'm not sure, just asking.
> Yes, totally forgot about it.
Thanks! LGTM.
>
> ====================
> diff --git a/src/lib/core/cord_buf.c b/src/lib/core/cord_buf.c
> index 9450d75bc..1d0fb3a41 100644
> --- a/src/lib/core/cord_buf.c
> +++ b/src/lib/core/cord_buf.c
> @@ -24,7 +24,7 @@ struct cord_buf {
> */
> struct trigger on_stop;
> struct trigger on_yield;
> -#if !NDEBUG
> +#ifndef NDEBUG
> /**
> * Fiber owning the buffer right now. Used for debug and sanity checks
> * only.
> @@ -52,7 +52,7 @@ cord_buf_set_owner(struct cord_buf *buf)
> struct fiber *f = fiber();
> trigger_add(&f->on_stop, &buf->on_stop);
> trigger_add(&f->on_yield, &buf->on_yield);
> -#if !NDEBUG
> +#ifndef NDEBUG
> buf->owner = f;
> #endif
> ibuf_reset(&buf->base);
> @@ -64,7 +64,7 @@ cord_buf_clear_owner(struct cord_buf *buf)
> assert(buf->owner == fiber());
> trigger_clear(&buf->on_stop);
> trigger_clear(&buf->on_yield);
> -#if !NDEBUG
> +#ifndef NDEBUG
> buf->owner = NULL;
> #endif
> }
> @@ -98,7 +98,7 @@ cord_buf_new(void)
> ibuf_create(&buf->base, &cord()->slabc, CORD_IBUF_START_CAPACITY);
> trigger_create(&buf->on_stop, cord_buf_on_stop, buf, NULL);
> trigger_create(&buf->on_yield, cord_buf_on_yield, buf, NULL);
> -#if !NDEBUG
> +#ifndef NDEBUG
> buf->owner = NULL;
> #endif
> return buf;
--
Serge Petrenko
next prev parent reply other threads:[~2021-03-23 7:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-20 0:42 [Tarantool-patches] [PATCH 00/16] Cord buffer, static alloc, and Lua GC bug Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 01/16] fio: don't use shared buffer in pread() Vladislav Shpilevoy via Tarantool-patches
2021-03-22 7:19 ` Cyrill Gorcunov via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 10/16] uri: replace static_alloc with ffi stash and ibuf Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 11/16] buffer: remove static_alloc() from Lua Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 12/16] lua: use lua_pushfstring() instead of tt_sprintf() Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 13/16] sio: rework sio_strfaddr() Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 14/16] sio: increase SERVICE_NAME_MAXLEN size Vladislav Shpilevoy via Tarantool-patches
2021-03-21 21:58 ` Cyrill Gorcunov via Tarantool-patches
2021-03-22 22:32 ` Vladislav Shpilevoy via Tarantool-patches
2021-03-23 6:56 ` Cyrill Gorcunov via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 15/16] sio: introduce and use sio_snprintf() Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 16/16] buffer: remove Lua registers Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 02/16] test: don't use IBUF_SHARED in the tests Vladislav Shpilevoy via Tarantool-patches
2021-03-22 7:35 ` Cyrill Gorcunov via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 03/16] tuple: pass global ibuf explicitly where possible Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 04/16] iconv: take errno before reseting the context Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 05/16] cord_buf: introduce cord_buf API Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 06/16] cord_buf: introduce ownership management Vladislav Shpilevoy via Tarantool-patches
2021-03-22 16:48 ` Serge Petrenko via Tarantool-patches
2021-03-22 22:32 ` Vladislav Shpilevoy via Tarantool-patches
2021-03-23 7:46 ` Serge Petrenko via Tarantool-patches [this message]
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 07/16] buffer: implement ffi stash Vladislav Shpilevoy via Tarantool-patches
2021-03-23 0:29 ` Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 08/16] uuid: replace static_alloc with " Vladislav Shpilevoy via Tarantool-patches
2021-03-20 0:42 ` [Tarantool-patches] [PATCH 09/16] uuid: drop tt_uuid_str() from Lua Vladislav Shpilevoy via Tarantool-patches
2021-03-21 16:38 ` [Tarantool-patches] [PATCH 00/16] Cord buffer, static alloc, and Lua GC bug Vladislav Shpilevoy via Tarantool-patches
2021-03-22 7:52 ` Cyrill Gorcunov via Tarantool-patches
2021-03-22 7:56 ` Konstantin Osipov via Tarantool-patches
2021-03-22 17:17 ` Serge Petrenko via Tarantool-patches
2021-03-23 23:45 ` Vladislav Shpilevoy via Tarantool-patches
2021-03-24 13:28 ` Kirill Yukhin via Tarantool-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c4aa232-351b-e0b6-d38a-66d0e51b846e@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=gorcunov@gmail.com \
--cc=sergepetrenko@tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 06/16] cord_buf: introduce ownership management' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox