mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-04-28 10:33:20 +00:00
Close socket when failed to connect name pipe
This commit is contained in:
parent
d6ba8f60dc
commit
d79fd086d4
@ -333,6 +333,7 @@ int searpc_named_pipe_client_connect(SearpcNamedPipeClient *client)
|
|||||||
g_strlcpy (servaddr.sun_path, client->path, sizeof(servaddr.sun_path));
|
g_strlcpy (servaddr.sun_path, client->path, sizeof(servaddr.sun_path));
|
||||||
if (connect(client->pipe_fd, (struct sockaddr *)&servaddr, (socklen_t)sizeof(servaddr)) < 0) {
|
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));
|
g_warning ("pipe client failed to connect to server: %s\n", strerror(errno));
|
||||||
|
close(client->pipe_fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,6 +365,7 @@ int searpc_named_pipe_client_connect(SearpcNamedPipeClient *client)
|
|||||||
DWORD mode = PIPE_READMODE_MESSAGE;
|
DWORD mode = PIPE_READMODE_MESSAGE;
|
||||||
if (!SetNamedPipeHandleState(pipe_fd, &mode, NULL, NULL)) {
|
if (!SetNamedPipeHandleState(pipe_fd, &mode, NULL, NULL)) {
|
||||||
G_WARNING_WITH_LAST_ERROR("Failed to set named pipe mode");
|
G_WARNING_WITH_LAST_ERROR("Failed to set named pipe mode");
|
||||||
|
CloseHandle (pipe_fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user