Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions fd.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,15 @@ int dill_fd_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
int rc = dill_fdin(s, deadline);
if(dill_slow(rc < 0)) return -1;
}
int rc = dill_fd_unblock(as);
dill_assert(rc == 0);
/* Accepted sockets need O_NONBLOCK and SO_NOSIGPIPE. */
int opt = fcntl(as, F_GETFL, 0);
if(opt == -1) opt = 0;
int rc = fcntl(as, F_SETFL, opt | O_NONBLOCK);
if(dill_slow(rc != 0)) {close(as); return -1;}
#ifdef SO_NOSIGPIPE
opt = 1;
setsockopt(as, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
#endif
return as;
}

Expand Down
3 changes: 0 additions & 3 deletions ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,6 @@ int dill_ipc_accept_mem(int s, struct dill_ipc_storage *mem, int64_t deadline) {
/* Try to get new connection in a non-blocking way. */
int as = dill_fd_accept(lst->fd, NULL, NULL, deadline);
if(dill_slow(as < 0)) {err = errno; goto error1;}
/* Set it to non-blocking mode. */
int rc = dill_fd_unblock(as);
if(dill_slow(rc < 0)) {err = errno; goto error2;}
/* Create the handle. */
int h = dill_ipc_makeconn(as, (struct dill_ipc_conn*)mem);
if(dill_slow(h < 0)) {err = errno; goto error2;}
Expand Down
3 changes: 0 additions & 3 deletions tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,6 @@ int dill_tcp_accept_mem(int s, struct dill_ipaddr *addr,
int as = dill_fd_accept(lst->fd, (struct sockaddr*)addr, &addrlen,
deadline);
if(dill_slow(as < 0)) {err = errno; goto error1;}
/* Set it to non-blocking mode. */
int rc = dill_fd_unblock(as);
if(dill_slow(rc < 0)) {err = errno; goto error2;}
/* Create the handle. */
int h = dill_tcp_makeconn(as, mem);
if(dill_slow(h < 0)) {err = errno; goto error2;}
Expand Down