diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2011-05-02 22:24:24 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2011-05-02 22:24:24 +0000 |
commit | eec210b2e4d847c224112c6cd053f26f9f3139da (patch) | |
tree | edba8d7c0ae30cd561b59cdcf5986a908e0510bc /usr.bin | |
parent | 7b60f187e0287739322daa3a573c7e5880d51293 (diff) |
set the TCP_NODELAY option for TCP connections
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/aucat/listen.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.bin/aucat/listen.c b/usr.bin/aucat/listen.c index d99d3d9f543..df6e1eb412f 100644 --- a/usr.bin/aucat/listen.c +++ b/usr.bin/aucat/listen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: listen.c,v 1.14 2011/04/28 06:19:57 ratchov Exp $ */ +/* $OpenBSD: listen.c,v 1.15 2011/05/02 22:24:23 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -21,6 +21,7 @@ #include <sys/un.h> #include <netinet/in.h> +#include <netinet/tcp.h> #include <netdb.h> #include <err.h> @@ -175,7 +176,7 @@ listen_revents(struct file *file, struct pollfd *pfd) struct listen *f = (struct listen *)file; struct sockaddr caddr; socklen_t caddrlen; - int sock; + int sock, opt; if (pfd->revents & POLLIN) { caddrlen = sizeof(caddrlen); @@ -190,6 +191,15 @@ listen_revents(struct file *file, struct pollfd *pfd) close(sock); return 0; } + if (f->path == NULL) { + opt = 1; + if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, + &opt, sizeof(int)) < 0) { + perror("setsockopt"); + close(sock); + return 0; + } + } if (sock_new(&sock_ops, sock) == NULL) { close(sock); return 0; |