From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (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 C743D4765E0 for ; Sat, 26 Dec 2020 22:03:30 +0300 (MSK) From: Sergey Ostanevich Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_7D42BEC3-7E05-480D-9FA8-A94A18782912" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Date: Sat, 26 Dec 2020 22:03:28 +0300 In-Reply-To: <20201226152615.GX9101@root> References: <20201226142225.GH5396@tarantool.org> <20201226152615.GX9101@root> 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 Kaplun Cc: tarantool-patches@dev.tarantool.org --Apple-Mail=_7D42BEC3-7E05-480D-9FA8-A94A18782912 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi!=20 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 >=20 > +/* > +** 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=E2=80=99s provider should preserve the = =E2=80=98initial size=E2=80=99 is some way? Should it create two or more buffers of the same size during = initialization? > +** If *data =3D=3D NULL stream stops. > +*/ > typedef size_t (*lj_wbuf_writer)(const void **data, size_t len, void = *opt); >=20 > /* 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 =3D=3D 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; > }; >=20 > -/* 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); >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > --=20 > Best regards, > Sergey Kaplun --Apple-Mail=_7D42BEC3-7E05-480D-9FA8-A94A18782912 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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=E2=80=99s provider should preserve the =E2=80=98initial = size=E2=80=99 is some way?
Should it create two or more = buffers of the same size during initialization?

+** If *data = =3D=3D 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 =3D=3D 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);

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

-- 
Best = regards,
Sergey = Kaplun

= --Apple-Mail=_7D42BEC3-7E05-480D-9FA8-A94A18782912--