diff --git a/common/dev_disconnect.c b/common/dev_disconnect.c index 0b380e141..8a3b98a19 100644 --- a/common/dev_disconnect.c +++ b/common/dev_disconnect.c @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include #include @@ -96,6 +98,15 @@ void dev_sabotage_fd(int fd) /* Close one. */ close(fds[0]); + +#if defined(TCP_NODELAY) + /* On Linux, at least, this flushes. */ + int opt = TCP_NODELAY; + int val = 1; + setsockopt(fd, IPPROTO_TCP, opt, &val, sizeof(val)); +#else +#error No TCP_NODELAY? +#endif /* Move other over to the fd we want to sabotage. */ dup2(fds[1], fd); close(fds[1]);