[Tarantool-patches] [PATCH 12/20] net.box: rewrite error decoder in C

Vladimir Davydov vdavydov at tarantool.org
Mon Aug 2 11:00:22 MSK 2021


On Sat, Jul 31, 2021 at 12:13:15AM +0200, Vladislav Shpilevoy wrote:
> > +		mp_next(data); /* skip value */
> 
> 1. Could you please write comments on their own lines if possible?

Done.

> > -ffi.cdef[[
> > -struct error *
> > -error_unpack_unsafe(const char **data);
> 
> 2. You should be able to remove it from exports.h now. It
> is not used by FFI anymore. (error_unref() should stay in
> export.h - it is used by error Lua module.)

Done.

> > -local response_decoder = {
> > -    [IPROTO_ERROR_24] = decode,
> > -    [IPROTO_ERROR] = decode_error,
> 
> 3. IPROTO_ERROR is now unused.

Removed.

Pushed all the changes to the branch and rebased.
The incremental diff is below:
--
diff --git a/src/box/lua/net_box.c b/src/box/lua/net_box.c
index 0914697f2b2e..e1f820926838 100644
--- a/src/box/lua/net_box.c
+++ b/src/box/lua/net_box.c
@@ -1051,7 +1051,7 @@ netbox_decode_method(struct lua_State *L)
 	return 2;
 }
 
-/*
+/**
  * Decodes an error from raw data and pushes it to Lua stack. Takes a pointer
  * to the data (char ptr) and an error code.
  */
@@ -1092,7 +1092,8 @@ netbox_decode_error(struct lua_State *L)
 			error_ref(error);
 			continue;
 		}
-		mp_next(data); /* skip value */
+		/* Skip value. */
+		mp_next(data);
 	}
 	if (error == NULL) {
 		/*
diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index c0c3c4098525..242b1c8d9314 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -41,7 +41,6 @@ local IPROTO_SYNC_KEY      = 0x01
 local IPROTO_SCHEMA_VERSION_KEY = 0x05
 local IPROTO_DATA_KEY      = 0x30
 local IPROTO_ERROR_24      = 0x31
-local IPROTO_ERROR         = 0x52
 local IPROTO_GREETING_SIZE = 128
 local IPROTO_CHUNK_KEY     = 128
 local IPROTO_OK_KEY        = 0
diff --git a/src/exports.h b/src/exports.h
index 5bb3e6a2b55a..7be6486f0075 100644
--- a/src/exports.h
+++ b/src/exports.h
@@ -220,7 +220,6 @@ EXPORT(curl_version_info)
 EXPORT(decimal_unpack)
 EXPORT(error_ref)
 EXPORT(error_set_prev)
-EXPORT(error_unpack_unsafe)
 EXPORT(error_unref)
 EXPORT(exception_get_int)
 EXPORT(exception_get_string)


More information about the Tarantool-patches mailing list