[Tarantool-patches] [PATCH v2 1/1] box: export box_session_push to the public C API
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Apr 12 17:15:16 MSK 2020
>>> The result value is not checked, but <port_msgpack_set_plain> returns -1
>>> when OOM occurs.
>>
>> No need to check result. port_mspack_set_plain() not only returns -1, it
>> also keeps port->plain NULL. If it is NULL, it is an error.
>>
>> port_mspack_dump_plain() returns port->plain. Therefore if there was an
>> error, it will return NULL with a correctly installed diag.
>
> OK, thanks, got it. It might be useful to drop a couple words regarding
> it. Feel free to ignore.
Done:
====================
diff --git a/src/box/lua/console.c b/src/box/lua/console.c
index c647c39d7..b941f50c6 100644
--- a/src/box/lua/console.c
+++ b/src/box/lua/console.c
@@ -465,10 +465,16 @@ port_msgpack_dump_plain_via_lua(struct lua_State *L)
*/
luamp_decode(L, luaL_msgpack_default, &data);
data = console_dump_plain(L, size);
- if (data == NULL)
+ if (data == NULL) {
assert(port->plain == NULL);
- else
+ } else {
+ /*
+ * Result is ignored, because in case of an error
+ * port->plain will stay NULL. And it will be
+ * returned by port_msgpack_dump_plain() as is.
+ */
port_msgpack_set_plain((struct port *)port, data, *size);
+ }
return 0;
}
@@ -493,6 +499,10 @@ port_msgpack_dump_plain(struct port *base, uint32_t *size)
lua_pop(L, 1);
return NULL;
}
+ /*
+ * If there was an error, port->plain stayed NULL with
+ * installed diag.
+ */
return ((struct port_msgpack *)base)->plain;
}
====================
More information about the Tarantool-patches
mailing list