aboutsummaryrefslogtreecommitdiff
path: root/chardev
diff options
context:
space:
mode:
Diffstat (limited to 'chardev')
-rw-r--r--chardev/char-socket.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 82c7d7a323..09aa345869 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -902,11 +902,22 @@ cleanup:
object_unref(OBJECT(sioc));
}
+static void tcp_chr_connect_async(Chardev *chr)
+{
+ SocketChardev *s = SOCKET_CHARDEV(chr);
+ QIOChannelSocket *sioc;
+
+ sioc = qio_channel_socket_new();
+ tcp_chr_set_client_ioc_name(chr, sioc);
+ qio_channel_socket_connect_async(sioc, s->addr,
+ qemu_chr_socket_connected,
+ chr, NULL, chr->gcontext);
+}
+
static gboolean socket_reconnect_timeout(gpointer opaque)
{
Chardev *chr = CHARDEV(opaque);
SocketChardev *s = SOCKET_CHARDEV(opaque);
- QIOChannelSocket *sioc;
g_source_unref(s->reconnect_timer);
s->reconnect_timer = NULL;
@@ -915,11 +926,7 @@ static gboolean socket_reconnect_timeout(gpointer opaque)
return false;
}
- sioc = qio_channel_socket_new();
- tcp_chr_set_client_ioc_name(chr, sioc);
- qio_channel_socket_connect_async(sioc, s->addr,
- qemu_chr_socket_connected,
- chr, NULL, NULL);
+ tcp_chr_connect_async(chr);
return false;
}
@@ -999,11 +1006,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
}
if (s->reconnect_time) {
- sioc = qio_channel_socket_new();
- tcp_chr_set_client_ioc_name(chr, sioc);
- qio_channel_socket_connect_async(sioc, s->addr,
- qemu_chr_socket_connected,
- chr, NULL, NULL);
+ tcp_chr_connect_async(chr);
} else {
if (s->is_listen) {
char *name;