1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-09-16 23:08:14 +00:00

Close socket when failed to connect name pipe (#65)

Co-authored-by: heran yang <heran.yang@seafile.com>
This commit is contained in:
feiniks
2023-05-27 14:57:05 +08:00
committed by GitHub
parent d6ba8f60dc
commit 783141fb69

View File

@@ -333,6 +333,7 @@ int searpc_named_pipe_client_connect(SearpcNamedPipeClient *client)
g_strlcpy (servaddr.sun_path, client->path, sizeof(servaddr.sun_path));
if (connect(client->pipe_fd, (struct sockaddr *)&servaddr, (socklen_t)sizeof(servaddr)) < 0) {
g_warning ("pipe client failed to connect to server: %s\n", strerror(errno));
close(client->pipe_fd);
return -1;
}
@@ -364,6 +365,7 @@ int searpc_named_pipe_client_connect(SearpcNamedPipeClient *client)
DWORD mode = PIPE_READMODE_MESSAGE;
if (!SetNamedPipeHandleState(pipe_fd, &mode, NULL, NULL)) {
G_WARNING_WITH_LAST_ERROR("Failed to set named pipe mode");
CloseHandle (pipe_fd);
return -1;
}