Skip to content

Commit

Permalink
Merge pull request #1153 from SirCmpwn/fix-1152
Browse files Browse the repository at this point in the history
Fix dangling file descriptors (fixes #1152)
  • Loading branch information
ddevault authored Apr 7, 2017
2 parents 270e01c + cf95aeb commit 4e12bf6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sway/ipc-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ int ipc_handle_connection(int fd, uint32_t mask, void *data) {
}

int flags;
if ((flags=fcntl(client_fd, F_GETFD)) == -1 || fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
if ((flags = fcntl(client_fd, F_GETFD)) == -1
|| fcntl(client_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
sway_log_errno(L_ERROR, "Unable to set CLOEXEC on IPC client socket");
close(client_fd);
return 0;
Expand Down Expand Up @@ -193,13 +194,12 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) {

if (mask & WLC_EVENT_ERROR) {
sway_log(L_ERROR, "IPC Client socket error, removing client");
client->fd = -1;
ipc_client_disconnect(client);
return 0;
}

if (mask & WLC_EVENT_HANGUP) {
client->fd = -1;
sway_log(L_DEBUG, "Client %d hung up", client->fd);
ipc_client_disconnect(client);
return 0;
}
Expand Down

0 comments on commit 4e12bf6

Please sign in to comment.