service: don't cache a service descriptor

Submitted by Andrei Vagin on April 23, 2018, 6:22 a.m.

Details

Message ID 20180423062251.7439-1-avagin@virtuozzo.com
State New
Series "service: don't cache a service descriptor"
Headers show

Commit Message

Andrei Vagin April 23, 2018, 6:22 a.m.
Service descriptros can be moved in a child process.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 criu/action-scripts.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/action-scripts.c b/criu/action-scripts.c
index 4fa8e2843..74d560a87 100644
--- a/criu/action-scripts.c
+++ b/criu/action-scripts.c
@@ -43,7 +43,6 @@  enum {
 };
 
 static int scripts_mode = SCRIPTS_NONE;
-static int rpc_sk;
 static LIST_HEAD(scripts);
 
 static int run_shell_scripts(const char *action)
@@ -103,10 +102,13 @@  static int run_shell_scripts(const char *action)
 int rpc_send_fd(enum script_actions act, int fd)
 {
 	const char *action = action_names[act];
+	int rpc_sk;
 
 	if (scripts_mode != SCRIPTS_RPC)
 		return -1;
 
+	rpc_sk = get_service_fd(RPC_SK_OFF);
+
 	pr_debug("\tRPC\n");
 	return send_criu_rpc_script(act, (char *)action, rpc_sk, fd);
 }
@@ -122,7 +124,10 @@  int run_scripts(enum script_actions act)
 		return 0;
 
 	if (scripts_mode == SCRIPTS_RPC) {
+		int rpc_sk;
+
 		pr_debug("\tRPC\n");
+		rpc_sk = get_service_fd(RPC_SK_OFF);
 		ret = send_criu_rpc_script(act, (char *)action, rpc_sk, -1);
 		goto out;
 	}
@@ -161,7 +166,8 @@  int add_rpc_notify(int sk)
 	BUG_ON(scripts_mode == SCRIPTS_SHELL);
 	scripts_mode = SCRIPTS_RPC;
 
-	rpc_sk = install_service_fd(RPC_SK_OFF, sk);
+	if (install_service_fd(RPC_SK_OFF, sk))
+		return -1;
 
 	return 0;
 }