From 0f53c82c81eecb70d55aec081854bc3346f5a7c9 Mon Sep 17 00:00:00 2001 From: Alexandr <a.lyapunov@corp.mail.ru> Date: Fri, 15 Aug 2014 18:31:53 +0400 Subject: [PATCH] fix gh-366 duplicate output --- src/box/box.cc | 4 ++++ src/box/replication.cc | 8 ++++++++ src/say.cc | 4 ++++ src/tarantool.cc | 4 ++++ src/util.cc | 4 ++++ test/app/cfg.result | 1 - test/app/pcall.result | 4 ---- 7 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index fab05906bb..1a61f5cb6e 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -496,6 +496,10 @@ box_snapshot(void) if (snapshot_pid) return EINPROGRESS; + /* flush buffers to avoid multiple output */ + /* https://github.com/tarantool/tarantool/issues/366 */ + fflush(stdout); + fflush(stderr); pid_t p = fork(); if (p < 0) { say_syserror("fork"); diff --git a/src/box/replication.cc b/src/box/replication.cc index 2651e5d652..9123146da9 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -172,6 +172,10 @@ replication_prefork(const char *snap_dir, const char *wal_dir) panic_syserror("socketpair"); assert(sockpair[0] != STDOUT_FILENO && sockpair[0] != STDERR_FILENO); + /* flush buffers to avoid multiple output */ + /* https://github.com/tarantool/tarantool/issues/366 */ + fflush(stdout); + fflush(stderr); /* create spawner */ pid_t pid = fork(); if (pid == -1) @@ -513,6 +517,10 @@ spawner_sigchld_handler(int signo __attribute__((unused))) static int spawner_create_replication_relay() { + /* flush buffers to avoid multiple output */ + /* https://github.com/tarantool/tarantool/issues/366 */ + fflush(stdout); + fflush(stderr); pid_t pid = fork(); if (pid < 0) { diff --git a/src/say.cc b/src/say.cc index 3cba2d42aa..aa46db152a 100644 --- a/src/say.cc +++ b/src/say.cc @@ -115,6 +115,10 @@ say_init_pipe() goto error; } + /* flush buffers to avoid multiple output */ + /* https://github.com/tarantool/tarantool/issues/366 */ + fflush(stdout); + fflush(stderr); logger_pid = fork(); if (logger_pid == -1) { say_syserror("pipe"); diff --git a/src/tarantool.cc b/src/tarantool.cc index fe46976d6d..8b189546fb 100644 --- a/src/tarantool.cc +++ b/src/tarantool.cc @@ -352,6 +352,10 @@ create_pid(void) static void background() { + /* flush buffers to avoid multiple output */ + /* https://github.com/tarantool/tarantool/issues/366 */ + fflush(stdout); + fflush(stderr); switch (fork()) { case -1: goto error; diff --git a/src/util.cc b/src/util.cc index 375fb87a75..6f30246714 100644 --- a/src/util.cc +++ b/src/util.cc @@ -110,6 +110,10 @@ coredump(int dump_interval) last_coredump = now; + /* flush buffers to avoid multiple output */ + /* https://github.com/tarantool/tarantool/issues/366 */ + fflush(stdout); + fflush(stderr); if (fork() == 0) { close_all_xcpt(0); #ifdef ENABLE_GCOV diff --git a/test/app/cfg.result b/test/app/cfg.result index 6aaed551fa..95ae0c7b72 100644 --- a/test/app/cfg.result +++ b/test/app/cfg.result @@ -1,3 +1,2 @@ false [string "-- load_cfg.lua - internal file..."]:97: Please call box.cfg{} first true table -false [string "-- load_cfg.lua - internal file..."]:97: Please call box.cfg{} first diff --git a/test/app/pcall.result b/test/app/pcall.result index 38429cee4f..3d1c559295 100644 --- a/test/app/pcall.result +++ b/test/app/pcall.result @@ -7,7 +7,3 @@ pcall with Lua error(): false some message pcall with box.error(): false Illegal parameters, some message pcall with no return: 1 pcall with multireturn: true 1 2 3 --------------------------------------------------------------------------------- --- #267: Bad exception catching --------------------------------------------------------------------------------- - -- GitLab