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 08D0B6FC8F; Tue, 23 Mar 2021 01:32:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 08D0B6FC8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1616452368; bh=A/rhVr50dRixZPSgzWVf9eIGZOzQwvd/TIiz2b2x3GA=; 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=KeS6TouMS38f6gn7GgWG6mfkGHBnIaw9NJJPTafs21Y2d5VhgavTMuQyRderlhDvX T7qYTYwbgurjmrc1LDSEQIEZuA31LyoZj7gumEBPzwJiKxWXCAG0d4wXaG7G4+jK53 qdixVR8uqU7YC1wFmXSRk6atQMLRgFKuqI4IOvbk= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 2459E7034A for ; Tue, 23 Mar 2021 01:32:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2459E7034A Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lOT5v-00087C-FZ; Tue, 23 Mar 2021 01:32:19 +0300 To: Serge Petrenko , tarantool-patches@dev.tarantool.org, gorcunov@gmail.com References: Message-ID: Date: Mon, 22 Mar 2021 23:32:18 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD95D6E7CC48CB1F5F179C48A9DDACBFB6F5347129BC2C9341C182A05F538085040AA34E3DDA1295169E8C0B6E281C192DEF38DD9C8E26796CC31518891D8509A38 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE75644E22E05AA81AEB287FD4696A6DC2FA8DF7F3B2552694A4E2F5AFA99E116B42401471946AA11AF176DF2183F8FC7C0547428DA4700DDEF8F08D7030A58E5ADC58D69EE07B14084C6CDE5D1141D2B1CB337D9F2B2ED467BE71BAB087FCBCE6CB3C896046F33F1D39FA2833FD35BB23D9E625A9149C048EE9ECD01F8117BC8BEA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF5012EF20D2F80756B5F868A13BD56FB6657A7F4EDE966BC389F9E8FC8737B5C22497393CE827C55B5F775ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4930A3850AC1BE2E735BAAD9279A72BC9ABC4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0FECB2555BB02FD5A93B503F486389A921A5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5864B0E885B010E6937772CACFCFDC678140E972EEC53E655D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A246DFF68F0EE19E1EC892086737598B15CA698DB628229E4CC065A7FFA3AEC5982F36A1F7CE7C371D7E09C32AA3244C6410B9DBDD7F7042CFD0CAFE2DDBD8B163871F383B54D9B3FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojWJZv20R+6Ug3RmNa80udRA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638222252D03EE849AAB1803EE3564944475B3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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. ==================== 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;