From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 493814765E0 for ; Sat, 26 Dec 2020 22:38:28 +0300 (MSK) Date: Sat, 26 Dec 2020 22:37:41 +0300 From: Sergey Kaplun Message-ID: <20201226193741.GY9101@root> References: <20201226142225.GH5396@tarantool.org> <20201226152615.GX9101@root> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH luajit v2 2/7] core: introduce write buffer module List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Ostanevich Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the review! On 26.12.20, Sergey Ostanevich wrote: > Hi! > > Thanks for the patch! > > Just one problem and LGTM otherwise. > > Sergos > > > --- a/src/lj_wbuf.h > > +++ b/src/lj_wbuf.h > > @@ -31,32 +31,32 @@ > > #define STREAM_ERR_IO 0x1 > > #define STREAM_STOP 0x2 > > > > +/* > > +** Buffer writer which is called on the buffer flush. > > +** Should return amount of written bytes on success or zero in case of error. > > +** *data should contain a buffer of at least the initial size. > > Does it mean the writer’s provider should preserve the ‘initial size’ is some way? Yes, inside `ctx`, for example. > Should it create two or more buffers of the same size during initialization? If necessary, but it is not required. This is the user's responsibility. > > > +** If *data == NULL stream stops. > > +*/ > > typedef size_t (*lj_wbuf_writer)(const void **data, size_t len, void *opt); > > > > /* Write buffer. */ > > struct lj_wbuf { > > - /* > > - ** Buffer writer which will called at buffer write. > > - ** Should return amount of written bytes on success or zero in case of error. > > - ** *data should contain new buffer of size greater or equal to len. > > - ** If *data == NULL stream stops. > > - */ > > lj_wbuf_writer writer; > > /* Context for writer function. */ > > void *ctx; > > /* Buffer size. */ > > size_t size; > > - /* Saved errno in case of error. */ > > - int saved_errno; > > /* Start of buffer. */ > > uint8_t *buf; > > /* Current position in buffer. */ > > uint8_t *pos; > > + /* Saved errno in case of error. */ > > + int saved_errno; > > /* Internal flags. */ > > volatile uint8_t flags; > > }; > > > > -/* Init buffer. */ > > +/* Initialize the buffer. */ > > void lj_wbuf_init(struct lj_wbuf *buf, lj_wbuf_writer writer, void *ctx, > > uint8_t *mem, size_t size); > > > > =================================================================== > > > > -- > > Best regards, > > Sergey Kaplun > -- Best regards, Sergey Kaplun