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
19 changes: 19 additions & 0 deletions fstrm/tcp_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@ fstrm__tcp_writer_op_open(void *obj)
}
#endif

#if defined(SO_RCVTIMEO) || defined(SO_SNDTIMEO)
static const struct timeval timeout = {
.tv_sec = 1,
.tv_usec = 0
};
#if defined(SO_RCVTIMEO)
if (setsockopt(w->fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) != 0) {
close(w->fd);
return fstrm_res_failure;
}
#endif
#if defined(SO_SNDTIMEO)
if (setsockopt(w->fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) != 0) {
close(w->fd);
return fstrm_res_failure;
}
#endif
#endif

/* Connect the TCP socket. */
if (connect(w->fd, (struct sockaddr *) &w->ss, w->ss_len) < 0) {
close(w->fd);
Expand Down
19 changes: 19 additions & 0 deletions fstrm/unix_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ fstrm__unix_writer_op_open(void *obj)
}
#endif

#if defined(SO_RCVTIMEO) || defined(SO_SNDTIMEO)
static const struct timeval timeout = {
.tv_sec = 1,
.tv_usec = 0
};
#if defined(SO_RCVTIMEO)
if (setsockopt(w->fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) != 0) {
close(w->fd);
return fstrm_res_failure;
}
#endif
#if defined(SO_SNDTIMEO)
if (setsockopt(w->fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) != 0) {
close(w->fd);
return fstrm_res_failure;
}
#endif
#endif

/* Connect the AF_UNIX socket. */
if (connect(w->fd, (struct sockaddr *) &w->sa, sizeof(w->sa)) < 0) {
close(w->fd);
Expand Down