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 8ACDD6ECC0; Mon, 6 Dec 2021 06:06:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8ACDD6ECC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1638759969; bh=eUsxpFAfXibyCO73HFbjialh0yCWKSiEnj6o7SFXhoI=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=fiGwxppC7akZ4OYP1CBKVnS2XZmXjZNc9EYK5e5UYfoXNLamDBT3QEfKdDFeAqNWO iSS/PXr6A1RVNhCOb3iDBzYHDg5//9+1zusGx7PkgflnSYcparkhubgE2pHaERhGXZ MPhxOmIVX5bE606qFWPP2iGJWDjS/0g7Vn2YVZcs= Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (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 6F3086ECC0 for ; Mon, 6 Dec 2021 06:06:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6F3086ECC0 Received: by smtp38.i.mail.ru with esmtpa (envelope-from ) id 1mu4KG-0000tX-C3; Mon, 06 Dec 2021 06:06:00 +0300 Message-ID: <8112214c-cfef-c791-80cf-fe4402540570@tarantool.org> Date: Mon, 6 Dec 2021 06:05:59 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Content-Language: en-GB To: v.shpilevoy@tarantool.org, vdavydov@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <76b802ed3cfa45a87f2610a9e05b71bc14dfb36a.1638757827.git.sergepetrenko@tarantool.org> In-Reply-To: <76b802ed3cfa45a87f2610a9e05b71bc14dfb36a.1638757827.git.sergepetrenko@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD93822B471089FF64D4E646BE16CEFF463156D8594F96ADA64182A05F53808504023BE08B62E16C0E07F2CDA61846A81523B655C5DAE2CA4CC880E93C1C9A23FB9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE789066434B85BF7C7EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B1BE0CF094621A628638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D83F29820EC8860FCD75C481DFD61C9C27117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EED76C6ED7039589DED94E105876FE7799D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE362B3BD3CC35DA588C0837EA9F3D19764C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F79006379FC65886B7F75608EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A55BFAF1EBC10EDFC5C188D1BA89D0BF978AD23D31440DDB5AD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7506FE1F977233B9BB410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34C75F910DBB8BE89833F56319CE3ED9FDEF085670C81A0CE299FAF5AA0C22AA131D390AB5230C21DF1D7E09C32AA3244C58F08D1440C2D15D6EFD53111BB85A5C6C24832127668422FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojk4oXTccdlol8oxrMbHHYOg== X-Mailru-Sender: 583F1D7ACE8F49BD7B46BC6C7C9DD5A8271D5279EAA4448CFBE8F86D063A199178FDDE4DEF16E5F3424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BCB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 1/4] xrow: rework coio_read_xrow to keep parsed input 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" Here's the corresponding change in libsmall: Subject: [PATCH] ibuf: introduce xpos field ibuf->xpos is the pointer to the not-yet-parsed input, so that rpos <= xpos <= wpos. This is useful when the user processes input in multiple stages, and needs the input data for a longer period of time than just "until the data is read". --- https://github.com/tarantool/small/tree/sp/ibuf-xpos include/small/ibuf.h | 10 +++++++++-  small/ibuf.c         |  4 +++-  2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/small/ibuf.h b/include/small/ibuf.h index 00d7781..a6646b5 100644 --- a/include/small/ibuf.h +++ b/include/small/ibuf.h @@ -61,6 +61,8 @@ struct ibuf      char *buf;      /** Start of input. */      char *rpos; +    /** End of parsed input. */ +    char *xpos;      /** End of useful input */      char *wpos;      /** End of buffer. */ @@ -100,6 +102,12 @@ ibuf_capacity(struct ibuf *ibuf)      return ibuf->end - ibuf->buf;  } +static inline size_t +ibuf_unparsed(struct ibuf *ibuf) +{ +    return ibuf->wpos - ibuf->xpos; +} +  /**   * Integer value of the position in the buffer - stable   * in case of realloc. @@ -115,7 +123,7 @@ ibuf_pos(struct ibuf *ibuf)  static inline void  ibuf_reset(struct ibuf *ibuf)  { -    ibuf->rpos = ibuf->wpos = ibuf->buf; +    ibuf->rpos = ibuf->xpos = ibuf->wpos = ibuf->buf;  }  void * diff --git a/small/ibuf.c b/small/ibuf.c index fe3f441..85345f4 100644 --- a/small/ibuf.c +++ b/small/ibuf.c @@ -37,7 +37,7 @@ void  ibuf_create(struct ibuf *ibuf, struct slab_cache *slabc, size_t start_capacity)  {      ibuf->slabc = slabc; -    ibuf->buf = ibuf->rpos = ibuf->wpos = ibuf->end = NULL; +    ibuf->buf = ibuf->rpos = ibuf->xpos = ibuf->wpos = ibuf->end = NULL;      ibuf->start_capacity = start_capacity;      /* Don't allocate the buffer yet. */  } @@ -99,7 +99,9 @@ ibuf_reserve_slow(struct ibuf *ibuf, size_t size)          ibuf->buf = ptr;          ibuf->end = ibuf->buf + slab_capacity(slab);      } +    size_t xsize = ibuf->xpos - ibuf->rpos;      ibuf->rpos = ibuf->buf; +    ibuf->xpos = ibuf->rpos + xsize;      ibuf->wpos = ibuf->rpos + used;      return ibuf->wpos;  } -- 2.30.1 (Apple Git-130) -- Serge Petrenko