[PATCH v3 4/6] box: export registered functions in box.func folder

Vladimir Davydov vdavydov.dev at gmail.com
Tue Jun 18 17:06:23 MSK 2019


On Thu, Jun 13, 2019 at 05:08:24PM +0300, Kirill Shcherbatov wrote:
> diff --git a/src/box/func.h b/src/box/func.h
> index 1271bde67..f7081eccd 100644
> --- a/src/box/func.h
> +++ b/src/box/func.h
> @@ -419,23 +418,20 @@ encode_lua_call_16(lua_State *L)
>  	 *
>  	 * TODO: forbid explicit yield from __serialize or __index here
>  	 */
> -	struct mpstream stream;
> -	mpstream_init(&stream, port->out, obuf_reserve_cb, obuf_alloc_cb,
> -		      luamp_error, port->L);
> -
>  	struct luaL_serializer *cfg = luaL_msgpack_default;
> -	port->size = luamp_encode_call_16(port->L, cfg, &stream);
> -	mpstream_flush(&stream);
> +	port->size = luamp_encode_call_16(port->L, cfg, port->stream);
> +	mpstream_flush(port->stream);
>  	return 0;
>  }
>  
>  static inline int
> -port_lua_do_dump(struct port *base, struct obuf *out, lua_CFunction handler)
> +port_lua_do_dump(struct port *base, struct mpstream *stream,
> +		 lua_CFunction handler)
>  {
> -	struct port_lua *port = (struct port_lua *)base;
> +	struct port_lua *port = (struct port_lua *) base;
>  	assert(port->vtab == &port_lua_vtab);
>  	/* Use port to pass arguments to encoder quickly. */
> -	port->out = out;
> +	port->stream = stream;

Why does mpstream (or obuf) have to be a member of port_lua? Just to
pass it to encode_lua_call? If so, let's please introduce an auxiliary
struct that would store port and mpstream while we are at it.

Other than that, the patch is good.



More information about the Tarantool-patches mailing list