[Devel] [PATCH 6/7] spfs: return duplicated socket from usernsd

Stanislav Kinsburskiy skinsbursky at virtuozzo.com
Wed Dec 20 19:07:16 MSK 2017


Usernsd closes socket when sent.

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

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

diff --git a/criu/spfs.c b/criu/spfs.c
index da19179..857a167 100644
--- a/criu/spfs.c
+++ b/criu/spfs.c
@@ -162,11 +162,19 @@ static int start_spfs_manager(void)
 static int get_spfs_mngr_sock(void *start, int fd, pid_t pid)
 {
 	int sock;
+	int sfd;
 
 	sock = get_service_fd(SPFS_MNGR_SK);
 	if (sock < 0 && start)
 		sock = start_spfs_manager();
-	return sock;
+	if (sock < 0)
+		return sock;
+
+	sfd = dup(sock);
+	if (sfd < 0)
+		pr_perror("failed to duplicate socket %d", sock);
+
+	return sfd;
 }
 
 static int request_spfs_mngr_sock(bool *start_mngr)



More information about the Devel mailing list