1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-04-27 18:25:06 +00:00

Close socket when failed to connect name pipe

This commit is contained in:
heran yang 2023-05-27 14:05:17 +08:00
parent d6ba8f60dc
commit d79fd086d4

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;
}