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 32C946EC55; Thu, 29 Jul 2021 01:51:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 32C946EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627512664; bh=REqo5AJyci1RDl+EwKklMhyBqCzaVutyeYRNP3uQuT8=; 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=zHBr+oWpYfOO7GI5vx3DvxgdzelB7MFcsKztDUDpeThEGpFrM3qudzpo5IMjUI0eC hdQBW7Y9Ht1rDR8/rysS1ZrQ+IheelbjVqQZtyVtnhsaJLf+GFp31WqVDrY+N+tniu JWtGDxJOI7dg3gErV4CyqmQ7gBYEhXKRudmaukmE= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [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 322AD6EC55 for ; Thu, 29 Jul 2021 01:51:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 322AD6EC55 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1m8sOE-0006gl-Cu; Thu, 29 Jul 2021 01:51:02 +0300 To: Vladimir Davydov , tarantool-patches@dev.tarantool.org References: <9cfb84719313537a78b68083923997c5ab2e3e62.1627024646.git.vdavydov@tarantool.org> Message-ID: <91e6d9c8-91ab-e057-9d42-9c84ab95c89d@tarantool.org> Date: Thu, 29 Jul 2021 00:51:01 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <9cfb84719313537a78b68083923997c5ab2e3e62.1627024646.git.vdavydov@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD941C43E597735A9C351B198F4576AC7B21928AAE70459C21B182A05F5380850406F8B975E3A2ADD351F543D64085AC7C1448B3599D28A6366A419E6AAC0FD7CAB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C4A7E4C0BFE8628DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374CC1EE7F84E0F1BE8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8C1A48D6FCD643E2B60D18AE391BCF08E117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FC26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505450CC5E296C4E36339E5FF82D9D3E41F X-C1DE0DAB: 0D63561A33F958A5B9D39186FFD262E35D01146408A812270109A312A1891B4CD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7536C62C4FBC402878410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3463DBE2ADA183F62F270B56265973E912F65767E10EFACF4DEA64BA7474C9B574C0C0221B828DA2781D7E09C32AA3244CC63BCCF73CF29A0526AF3D08E182353B8A6D4CC6FBFAC251729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojPp/mPgZxawFPXqzDKqZdUA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D9B8854A63B46738557021C93F8549C893841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 09/20] net.box: rewrite request encoder in C 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" Thanks for the patch! See 2 comments below. > diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c > index 8952efb7bb39..49030aabea69 100644 > --- a/src/box/lua/net_box.c > +++ b/src/box/lua/net_box.c > @@ -52,16 +52,34 @@ <...> > static inline size_t > -netbox_prepare_request(lua_State *L, struct mpstream *stream, uint32_t r_type) > +netbox_prepare_request(struct mpstream *stream, uint64_t sync, > + enum iproto_type type) > { > - struct ibuf *ibuf = (struct ibuf *) lua_topointer(L, 1); > - uint64_t sync = luaL_touint64(L, 2); > - > - mpstream_init(stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb, > - luamp_error, L); > - > /* Remember initial size of ibuf (see netbox_encode_request()) */ > + struct ibuf *ibuf = (struct ibuf *) stream->ctx; 1. There is a rule now that in the new code after unary operators we do not put whitespaces. But here you do not need a cast. In C void * to any other pointer works implicitly. Here and in other new places. > @@ -108,16 +126,15 @@ netbox_encode_request(struct mpstream *stream, size_t initial_size) > mp_store_u32(fixheader, total_size - fixheader_size); > } > > -static int > -netbox_encode_ping(lua_State *L) > +static void > +netbox_encode_ping(lua_State *L, int idx, struct ibuf *ibuf, uint64_t sync) > { > - if (lua_gettop(L) < 2) > - return luaL_error(L, "Usage: netbox.encode_ping(ibuf, sync)"); > - > + (void) idx; > struct mpstream stream; > - size_t svp = netbox_prepare_request(L, &stream, IPROTO_PING); > + mpstream_init(&stream, ibuf, ibuf_reserve_cb, ibuf_alloc_cb, > + luamp_error, L); > + size_t svp = netbox_prepare_request(&stream, sync, IPROTO_PING); 2. mpstream_init and netbox_prepare_request in 100% cases go together. Maybe you could move the init into netbox_prepare_request? It even takes the stream pointer already. You would only need to pass L again.