From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 4716B6FC8F; Tue, 23 Mar 2021 10:46:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4716B6FC8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616485568; bh=qBleSaNpyjsFXszUOdaahFUzLpQNkJ76aLUbUC7XteQ=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=V8uxHKS/yZEWP0ahv50xNKaKsbuYRL8tYApNfV9U+zD24MFkDkrpJAI0KFgJ/HnEi reXgK69rBWXKRM+CPjrVZVjZQfPsxphZdWVyB3WSb/wyFUMKlTrt0h/U/NkAvc5qtX qW55MMkK3o10dGzcFXsCZsiuB3v1r/cwANQMR2oA= Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 60A426FC8F for ; Tue, 23 Mar 2021 10:46:06 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 60A426FC8F Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1lObjp-0006bC-Kl; Tue, 23 Mar 2021 10:46:06 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com References: Message-ID: <4c4aa232-351b-e0b6-d38a-66d0e51b846e@tarantool.org> Date: Tue, 23 Mar 2021 10:46:05 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: ru X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD95D6E7CC48CB1F5F146FB1591D6F88157BC7E60153CA0047A182A05F5380850409603E9768793ECF28F47F747606F07FBC7C08193D46AA45DD7046B2BD507C12A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BB17EE3498E810FEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375AC38C7EC4509C8B8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95C686AF563A045C75EBB9EF0B01D3E78C8FC0EEA0188653F2FA471835C12D1D9774AD6D5ED66289B5259CC434672EE6371117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE71AE4D56B06699BBC9FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7EF792C8C49DED479D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED62991661749BA6B97735883F579433B02461CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF5012EF20D2F80756B5F868A13BD56FB6657A7F4EDE966BC389F9E8FC8737B5C224945423645B6F85954089D37D7C0E48F6CCF19DD082D7633A0E7DDDDC251EA7DABAAAE862A0553A39223F8577A6DFFEA7C1FF0638608E83E3943847C11F186F3C5E7DDDDC251EA7DABCC89B49CDF41148FA8EF81845B15A4842623479134186CDE6BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A515E2211ED0C09C226CB99CFAA187E39EAFE27E192A50B393D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D8C933888226C8414AE6737E979CA330246FA3DBE16BFD5432C8F145057CF3FBF052CD5D9B02B4A21D7E09C32AA3244CE8DCEF2CAA4D6BE0770797B25D0D3710250262A5EE9971B0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWJZv20R+6Ug7Tyloy1oi5A== X-Mailru-Sender: 583F1D7ACE8F49BDD2846D59FC20E9F841F3387A2ADFCCC215D3DF1A4FC86AFB1C4622495F56DB38424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 06/16] cord_buf: introduce ownership management X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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