Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Igor Munkin <imun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 1/1] box: export box_session_push to the public C API
Date: Sun, 12 Apr 2020 16:15:16 +0200	[thread overview]
Message-ID: <2ee28a74-f044-4783-2843-aa41505b34b2@tarantool.org> (raw)
In-Reply-To: <20200411181128.GI5713@tarantool.org>

>>> 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;
 }
====================

  reply	other threads:[~2020-04-12 14:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 23:20 Vladislav Shpilevoy
2020-04-08 15:33 ` Igor Munkin
2020-04-08 20:35   ` Vladislav Shpilevoy
2020-04-11  9:38     ` Igor Munkin
2020-04-11 18:11       ` Vladislav Shpilevoy
2020-04-11 18:11         ` Igor Munkin
2020-04-12 14:15           ` Vladislav Shpilevoy [this message]
2020-04-14  7:54 ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ee28a74-f044-4783-2843-aa41505b34b2@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=imun@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 1/1] box: export box_session_push to the public C API' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox