Blame 0001-char-Split-out-tcp-socket-close-code-in-a-separate-f.patch

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