|
Hans de Goede |
329b58 |
From 5b79aa329a378537ec939cee75df10ca073b367f Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
d4cdad |
From: Amit Shah <amit.shah@redhat.com>
|
|
Justin M. Forbes |
d4cdad |
Date: Mon, 21 Mar 2011 21:57:47 +0100
|
|
Hans de Goede |
329b58 |
Subject: [PATCH 101/114] char: Split out tcp socket close code in a separate
|
|
Justin M. Forbes |
d4cdad |
function
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
Signed-off-by: Amit Shah <amit.shah@redhat.com>
|
|
Justin M. Forbes |
d4cdad |
---
|
|
Justin M. Forbes |
d4cdad |
qemu-char.c | 25 ++++++++++++++++---------
|
|
Hans de Goede |
329b58 |
1 file changed, 16 insertions(+), 9 deletions(-)
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
diff --git a/qemu-char.c b/qemu-char.c
|
|
Hans de Goede |
329b58 |
index fe1126f..78d2a69 100644
|
|
Justin M. Forbes |
d4cdad |
--- a/qemu-char.c
|
|
Justin M. Forbes |
d4cdad |
+++ b/qemu-char.c
|
|
Hans de Goede |
329b58 |
@@ -2141,6 +2141,21 @@ typedef struct {
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
static void tcp_chr_accept(void *opaque);
|
|
Hans de Goede |
329b58 |
|
|
Justin M. Forbes |
d4cdad |
+static void tcp_closed(void *opaque)
|
|
Justin M. Forbes |
d4cdad |
+{
|
|
Justin M. Forbes |
d4cdad |
+ CharDriverState *chr = opaque;
|
|
Justin M. Forbes |
d4cdad |
+ TCPCharDriver *s = chr->opaque;
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
+ s->connected = 0;
|
|
Justin M. Forbes |
d4cdad |
+ if (s->listen_fd >= 0) {
|
|
Justin M. Forbes |
d4cdad |
+ qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
|
|
Justin M. Forbes |
d4cdad |
+ }
|
|
Justin M. Forbes |
d4cdad |
+ qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
|
|
Justin M. Forbes |
d4cdad |
+ closesocket(s->fd);
|
|
Justin M. Forbes |
d4cdad |
+ s->fd = -1;
|
|
Justin M. Forbes |
d4cdad |
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
|
|
Justin M. Forbes |
d4cdad |
+}
|
|
Justin M. Forbes |
d4cdad |
+
|
|
Justin M. Forbes |
d4cdad |
static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
|
|
Justin M. Forbes |
d4cdad |
{
|
|
Justin M. Forbes |
d4cdad |
TCPCharDriver *s = chr->opaque;
|
|
Hans de Goede |
329b58 |
@@ -2291,15 +2306,7 @@ static void tcp_chr_read(void *opaque)
|
|
Justin M. Forbes |
d4cdad |
len = s->max_size;
|
|
Justin M. Forbes |
d4cdad |
size = tcp_chr_recv(chr, (void *)buf, len);
|
|
Justin M. Forbes |
d4cdad |
if (size == 0) {
|
|
Justin M. Forbes |
d4cdad |
- /* connection closed */
|
|
Justin M. Forbes |
d4cdad |
- s->connected = 0;
|
|
Justin M. Forbes |
d4cdad |
- if (s->listen_fd >= 0) {
|
|
Justin M. Forbes |
d4cdad |
- qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
|
|
Justin M. Forbes |
d4cdad |
- }
|
|
Justin M. Forbes |
d4cdad |
- qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
|
|
Justin M. Forbes |
d4cdad |
- closesocket(s->fd);
|
|
Justin M. Forbes |
d4cdad |
- s->fd = -1;
|
|
Justin M. Forbes |
d4cdad |
- qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
|
|
Justin M. Forbes |
d4cdad |
+ tcp_closed(chr);
|
|
Justin M. Forbes |
d4cdad |
} else if (size > 0) {
|
|
Justin M. Forbes |
d4cdad |
if (s->do_telnetopt)
|
|
Justin M. Forbes |
d4cdad |
tcp_chr_process_IAC_bytes(chr, s, buf, &size);
|
|
Justin M. Forbes |
d4cdad |
--
|
|
Hans de Goede |
329b58 |
1.7.10.4
|
|
Justin M. Forbes |
d4cdad |
|