|
Justin M. Forbes |
5e10b1 |
From 47d0d4d2d16bdbb3e80b6c9a29b9db3f81f1d6fd Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
3f1f29 |
From: Amit Shah <amit.shah@redhat.com>
|
|
Hans de Goede |
3f1f29 |
Date: Mon, 21 Mar 2011 21:57:47 +0100
|
|
Justin M. Forbes |
5e10b1 |
Subject: [PATCH 01/13] char: Split out tcp socket close code in a separate
|
|
Hans de Goede |
3f1f29 |
function
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
Signed-off-by: Amit Shah <amit.shah@redhat.com>
|
|
Hans de Goede |
3f1f29 |
---
|
|
Hans de Goede |
3f1f29 |
qemu-char.c | 25 ++++++++++++++++---------
|
|
Hans de Goede |
3f1f29 |
1 files changed, 16 insertions(+), 9 deletions(-)
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
diff --git a/qemu-char.c b/qemu-char.c
|
|
Justin M. Forbes |
5e10b1 |
index dcf7065..1701bdf 100644
|
|
Hans de Goede |
3f1f29 |
--- a/qemu-char.c
|
|
Hans de Goede |
3f1f29 |
+++ b/qemu-char.c
|
|
Justin M. Forbes |
5e10b1 |
@@ -1945,6 +1945,21 @@ typedef struct {
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
static void tcp_chr_accept(void *opaque);
|
|
Hans de Goede |
3f1f29 |
|
|
Hans de Goede |
3f1f29 |
+static void tcp_closed(void *opaque)
|
|
Hans de Goede |
3f1f29 |
+{
|
|
Hans de Goede |
3f1f29 |
+ CharDriverState *chr = opaque;
|
|
Hans de Goede |
3f1f29 |
+ TCPCharDriver *s = chr->opaque;
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
+ s->connected = 0;
|
|
Hans de Goede |
3f1f29 |
+ if (s->listen_fd >= 0) {
|
|
Hans de Goede |
3f1f29 |
+ qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
|
|
Hans de Goede |
3f1f29 |
+ }
|
|
Hans de Goede |
3f1f29 |
+ qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
|
|
Hans de Goede |
3f1f29 |
+ closesocket(s->fd);
|
|
Hans de Goede |
3f1f29 |
+ s->fd = -1;
|
|
Hans de Goede |
3f1f29 |
+ qemu_chr_event(chr, CHR_EVENT_CLOSED);
|
|
Hans de Goede |
3f1f29 |
+}
|
|
Hans de Goede |
3f1f29 |
+
|
|
Hans de Goede |
3f1f29 |
static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
|
|
Hans de Goede |
3f1f29 |
{
|
|
Hans de Goede |
3f1f29 |
TCPCharDriver *s = chr->opaque;
|
|
Justin M. Forbes |
5e10b1 |
@@ -2095,15 +2110,7 @@ static void tcp_chr_read(void *opaque)
|
|
Hans de Goede |
3f1f29 |
len = s->max_size;
|
|
Hans de Goede |
3f1f29 |
size = tcp_chr_recv(chr, (void *)buf, len);
|
|
Hans de Goede |
3f1f29 |
if (size == 0) {
|
|
Hans de Goede |
3f1f29 |
- /* connection closed */
|
|
Hans de Goede |
3f1f29 |
- s->connected = 0;
|
|
Hans de Goede |
3f1f29 |
- if (s->listen_fd >= 0) {
|
|
Hans de Goede |
3f1f29 |
- qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
|
|
Hans de Goede |
3f1f29 |
- }
|
|
Hans de Goede |
3f1f29 |
- qemu_set_fd_handler(s->fd, NULL, NULL, NULL);
|
|
Hans de Goede |
3f1f29 |
- closesocket(s->fd);
|
|
Hans de Goede |
3f1f29 |
- s->fd = -1;
|
|
Hans de Goede |
3f1f29 |
- qemu_chr_event(chr, CHR_EVENT_CLOSED);
|
|
Hans de Goede |
3f1f29 |
+ tcp_closed(chr);
|
|
Hans de Goede |
3f1f29 |
} else if (size > 0) {
|
|
Hans de Goede |
3f1f29 |
if (s->do_telnetopt)
|
|
Hans de Goede |
3f1f29 |
tcp_chr_process_IAC_bytes(chr, s, buf, &size);
|
|
Hans de Goede |
3f1f29 |
--
|
|
Hans de Goede |
3f1f29 |
1.7.5.1
|
|
Hans de Goede |
3f1f29 |
|