From bacd3c070a4be628fd481216e26ddaac45b50f0a Mon Sep 17 00:00:00 2001
From: "Dmitry E. Oboukhov" <unera@debian.org>
Date: Wed, 24 Sep 2014 23:36:26 +0400
Subject: [PATCH] Reinit coeio after fork. #517

---
 src/coeio.cc     | 10 ++++++++++
 src/coeio.h      |  1 +
 src/tarantool.cc |  2 ++
 3 files changed, 13 insertions(+)

diff --git a/src/coeio.cc b/src/coeio.cc
index 223b5223c5..0bcd800b64 100644
--- a/src/coeio.cc
+++ b/src/coeio.cc
@@ -107,6 +107,16 @@ coeio_init(void)
 	ev_async_start(loop(), &coeio_manager.coeio_async);
 }
 
+/**
+ * ReInit coeio subsystem (for example after 'fork')
+ *
+ */
+void
+coeio_reinit(void)
+{
+	eio_init(coeio_want_poll_cb, NULL);
+}
+
 /**
  * A single task context.
  */
diff --git a/src/coeio.h b/src/coeio.h
index e0fdc8885d..6536063c55 100644
--- a/src/coeio.h
+++ b/src/coeio.h
@@ -57,6 +57,7 @@ extern "C" {
  */
 
 void coeio_init(void);
+void coeio_reinit(void);
 ssize_t coeio_custom(ssize_t (*f)(va_list ap), ev_tstamp timeout, ...);
 
 struct addrinfo *
diff --git a/src/tarantool.cc b/src/tarantool.cc
index 92f360034d..c7c4830871 100644
--- a/src/tarantool.cc
+++ b/src/tarantool.cc
@@ -367,6 +367,8 @@ background()
 	if (setsid() == -1)
 		goto error;
 
+	/* reinit coeio after fork (because libeio required it) */
+	coeio_reinit();
 	/*
 	 * Prints to stdout on failure, so got to be done before
 	 * we close it.
-- 
GitLab