[Tarantool-patches] [PATCH] xlog: fix arguments processing in commit 8e429f4b7

Cyrill Gorcunov gorcunov at gmail.com
Thu Mar 4 17:25:15 MSK 2021

The order of evaluation of arguments passed to a function
is not a part of language standart but compiler specifics.
Thus make sure we pass proper "errno" to xdir_say_gc.

Note that this is not critical issue: in case of hit
we simply get wrong syserror message when file not
present on a storage device.

Reported-by: Aleksandr Lyapunov <alyapunov at tarantool.org>
Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
Guys, I didn't create a branch for this fix since it is not
critical and there is no issue for it. Even if the problem
occurs it won't affect the workflow so it is rather a cosmetic

 src/box/xlog.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/box/xlog.c b/src/box/xlog.c
index 974f460be..462245d27 100644
--- a/src/box/xlog.c
+++ b/src/box/xlog.c
@@ -684,10 +684,13 @@ xdir_collect_garbage(struct xdir *dir, int64_t signature, unsigned flags)
 	       vclock_sum(vclock) < signature) {
 		const char *filename =
 			xdir_format_filename(dir, vclock_sum(vclock), NONE);
-		if (flags & XDIR_GC_ASYNC)
+		if (flags & XDIR_GC_ASYNC) {
 			eio_unlink(filename, 0, xdir_complete_gc, NULL);
-		else
-			xdir_say_gc(unlink(filename), errno, filename);
+		} else {
+			int rc = unlink(filename);
+			int _errno = rc != 0 ? errno : 0;
+			xdir_say_gc(rc, _errno, filename);
+		}
 		vclockset_remove(&dir->index, vclock);

More information about the Tarantool-patches mailing list