[v2,6/7] spfs: return duplicated socket from usernsd

Submitted by Stanislav Kinsburskiy on Dec. 21, 2017, 11:07 a.m.

Details

Message ID 20171221110724.1002189.72974.stgit@skinsbursky-vz7.qa.sw.ru
State New
Series "spfs: duplicate socket before sending it from usernsd"
Headers show

Commit Message

Stanislav Kinsburskiy Dec. 21, 2017, 11:07 a.m.
Usernsd closes socket when sent.

https://jira.sw.ru/browse/PSBM-79462

v2: duplicate only service descriptor

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 criu/spfs.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/spfs.c b/criu/spfs.c
index 7ce30e7..6ce2ac8 100644
--- a/criu/spfs.c
+++ b/criu/spfs.c
@@ -164,8 +164,13 @@  static int get_spfs_mngr_sock(void *start, int fd, pid_t pid)
 	int sock;
 
 	sock = get_service_fd(SPFS_MNGR_SK);
-	if (sock < 0 && start)
+	if (sock != -1) {
+		sock = dup(sock);
+		if (sock < 0)
+			pr_perror("failed to duplicate SPFS manager socket\n");
+	} else if (start)
 		sock = start_spfs_manager();
+
 	return sock;
 }