render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

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

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