aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2007-01-28 00:10:01 +0000
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>2007-01-28 00:10:01 +0000
commitf749998939e564d8b8363bd6148b7a067d6bc9e3 (patch)
treeff23ba93a0ff99d1f8e445a86690fe848c819ebb /vl.c
parente5b0bc445ed7edb1738aabb982a387ee38da1655 (diff)
Add nodelay option for TCP character devices.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2362 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/vl.c b/vl.c
index 0bacd04802..afd478e275 100644
--- a/vl.c
+++ b/vl.c
@@ -2497,6 +2497,12 @@ static void tcp_chr_telnet_init(int fd)
send(fd, (char *)buf, 3, 0);
}
+static void socket_set_nodelay(int fd)
+{
+ int val = 1;
+ setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
+}
+
static void tcp_chr_accept(void *opaque)
{
CharDriverState *chr = opaque;
@@ -2530,6 +2536,8 @@ static void tcp_chr_accept(void *opaque)
}
}
socket_set_nonblock(fd);
+ if (s->do_nodelay)
+ socket_set_nodelay(fd);
s->fd = fd;
qemu_set_fd_handler(s->listen_fd, NULL, NULL, NULL);
tcp_chr_connect(chr);
@@ -2554,6 +2562,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
int fd = -1, ret, err, val;
int is_listen = 0;
int is_waitconnect = 1;
+ int do_nodelay = 0;
const char *ptr;
struct sockaddr_in saddr;
#ifndef _WIN32
@@ -2584,6 +2593,8 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
is_listen = 1;
} else if (!strncmp(ptr,"nowait",6)) {
is_waitconnect = 0;
+ } else if (!strncmp(ptr,"nodelay",6)) {
+ do_nodelay = 1;
} else {
printf("Unknown option: %s\n", ptr);
goto fail;
@@ -2616,6 +2627,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
s->fd = -1;
s->listen_fd = -1;
s->is_unix = is_unix;
+ s->do_nodelay = do_nodelay && !is_unix;
chr->opaque = s;
chr->chr_write = tcp_chr_write;
@@ -2665,6 +2677,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
}
}
s->fd = fd;
+ socket_set_nodelay(fd);
if (s->connected)
tcp_chr_connect(chr);
else