[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 14/18] char: remove qemu_chr_finish_socket_connec
From: |
Daniel P. Berrange |
Subject: |
[Qemu-devel] [PATCH v2 14/18] char: remove qemu_chr_finish_socket_connection method |
Date: |
Thu, 10 Mar 2016 17:27:01 +0000 |
The qemu_chr_finish_socket_connection method is multiplexing two
different actions into one method. Each caller of it though, only
wants one specific action. The code is shorter & clearer if we
thus remove the method and just inline the specific actions
where needed.
Signed-off-by: Daniel P. Berrange <address@hidden>
---
qemu-char.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index e0147f3..fe212b4 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3091,20 +3091,6 @@ static void tcp_chr_close(CharDriverState *chr)
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
}
-static void qemu_chr_finish_socket_connection(CharDriverState *chr,
- QIOChannelSocket *sioc)
-{
- TCPCharDriver *s = chr->opaque;
-
- if (s->is_listen) {
- s->listen_ioc = sioc;
- s->listen_tag = qio_channel_add_watch(
- QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
- } else {
- tcp_chr_new_client(chr, sioc);
- object_unref(OBJECT(sioc));
- }
-}
static void qemu_chr_socket_connected(Object *src, Error *err, void *opaque)
{
@@ -3119,7 +3105,8 @@ static void qemu_chr_socket_connected(Object *src, Error
*err, void *opaque)
}
s->connect_err_reported = false;
- qemu_chr_finish_socket_connection(chr, sioc);
+ tcp_chr_new_client(chr, sioc);
+ object_unref(OBJECT(sioc));
}
static bool qemu_chr_open_socket_fd(CharDriverState *chr, Error **errp)
@@ -3131,7 +3118,9 @@ static bool qemu_chr_open_socket_fd(CharDriverState *chr,
Error **errp)
if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {
goto fail;
}
- qemu_chr_finish_socket_connection(chr, sioc);
+ s->listen_ioc = sioc;
+ s->listen_tag = qio_channel_add_watch(
+ QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
} else if (s->reconnect_time) {
qio_channel_socket_connect_async(sioc, s->addr,
qemu_chr_socket_connected,
@@ -3140,7 +3129,8 @@ static bool qemu_chr_open_socket_fd(CharDriverState *chr,
Error **errp)
if (qio_channel_socket_connect_sync(sioc, s->addr, errp) < 0) {
goto fail;
}
- qemu_chr_finish_socket_connection(chr, sioc);
+ tcp_chr_new_client(chr, sioc);
+ object_unref(OBJECT(sioc));
}
return true;
--
2.5.0
- [Qemu-devel] [PATCH v2 06/18] io: set correct error object in background reader test thread, (continued)
- [Qemu-devel] [PATCH v2 06/18] io: set correct error object in background reader test thread, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 07/18] io: assert errors before asserting content in I/O test, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 05/18] io: wait for incoming client in socket test, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 04/18] io: bind to socket before creating QIOChannelSocket, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 12/18] io: remove checking of EWOULDBLOCK, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 08/18] io: fix copy+paste mistake in socket error message, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 09/18] io: pass HANDLE to g_source_add_poll on Win32, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 11/18] io: use qemu_accept to ensure SOCK_CLOEXEC is set, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 13/18] io: implement socket watch for win32 using WSAEventSelect+select, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 10/18] io: introduce qio_channel_create_socket_watch, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 14/18] char: remove qemu_chr_finish_socket_connection method,
Daniel P. Berrange <=
- [Qemu-devel] [PATCH v2 16/18] char: remove qemu_chr_open_socket_fd method, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 15/18] char: remove socket_try_connect method, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 18/18] osdep: remove use of socket_error() from all code, Daniel P. Berrange, 2016/03/10
- [Qemu-devel] [PATCH v2 17/18] osdep: add wrappers for socket functions, Daniel P. Berrange, 2016/03/10
- Re: [Qemu-devel] [PATCH v2 00/18] Multiple fixes & improvements to QIOChannel & Win32, Paolo Bonzini, 2016/03/10