qemu/0402-char-Split-out-tcp-socket-close-code-in-a-separate-f.patch

55 lines
1.8 KiB
Diff
Raw Normal View History

From d33363c7732da489e69312949741181a59766bb2 Mon Sep 17 00:00:00 2001
2012-01-13 19:46:23 +00:00
From: Amit Shah <amit.shah@redhat.com>
Date: Mon, 21 Mar 2011 21:57:47 +0100
2012-10-28 18:05:07 +00:00
Subject: [PATCH] char: Split out tcp socket close code in a separate function
2012-01-13 19:46:23 +00:00
Signed-off-by: Amit Shah <amit.shah@redhat.com>
2012-08-28 15:15:48 +00:00
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2012-01-13 19:46:23 +00:00
---
qemu-char.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
2012-01-13 19:46:23 +00:00
diff --git a/qemu-char.c b/qemu-char.c
2012-10-28 18:05:07 +00:00
index b082bae..a1fdf88 100644
2012-01-13 19:46:23 +00:00
--- a/qemu-char.c
+++ b/qemu-char.c
2012-10-28 18:05:07 +00:00
@@ -2141,6 +2141,21 @@ typedef struct {
2012-10-28 18:05:07 +00:00
static void tcp_chr_accept(void *opaque);
2012-01-13 19:46:23 +00:00
+static void tcp_closed(void *opaque)
+{
+ CharDriverState *chr = opaque;
+ TCPCharDriver *s = chr->opaque;
+
+ s->connected = 0;
+ if (s->listen_fd >= 0) {
+ qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
+ }
+ qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
+ closesocket(s->fd);
+ s->fd = -1;
+ qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
+}
+
static int tcp_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
{
TCPCharDriver *s = chr->opaque;
2012-10-28 18:05:07 +00:00
@@ -2299,15 +2314,7 @@ static void tcp_chr_read(void *opaque)
2012-01-13 19:46:23 +00:00
len = s->max_size;
size = tcp_chr_recv(chr, (void *)buf, len);
if (size == 0) {
- /* connection closed */
- s->connected = 0;
- if (s->listen_fd >= 0) {
- qemu_set_fd_handler2(s->listen_fd, NULL, tcp_chr_accept, NULL, chr);
- }
- qemu_set_fd_handler2(s->fd, NULL, NULL, NULL, NULL);
- closesocket(s->fd);
- s->fd = -1;
- qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
+ tcp_closed(chr);
} else if (size > 0) {
if (s->do_telnetopt)
tcp_chr_process_IAC_bytes(chr, s, buf, &size);