aboutsummaryrefslogtreecommitdiff
path: root/chardev
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2016-12-20 15:32:31 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2017-05-04 15:34:41 +0400
commitbbcde969b242fc4b3ab84097f7783cfe0920e69f (patch)
treed2b9f4ebf9887b311f86e81d67561fb7af85337e /chardev
parente1f98fe48a049366e754c055cc3ea99dcf6cb688 (diff)
char-socket: introduce update_disconnected_filename()
This helper will be used in yet another place in the following patch. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Diffstat (limited to 'chardev')
-rw-r--r--chardev/char-socket.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 2789eb1f40..511a82960d 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -366,6 +366,15 @@ static char *SocketAddress_to_str(const char *prefix, SocketAddress *addr,
}
}
+static void update_disconnected_filename(SocketChardev *s)
+{
+ Chardev *chr = CHARDEV(s);
+
+ g_free(chr->filename);
+ chr->filename = SocketAddress_to_str("disconnected:", s->addr,
+ s->is_listen, s->is_telnet);
+}
+
static void tcp_chr_disconnect(Chardev *chr)
{
SocketChardev *s = SOCKET_CHARDEV(chr);
@@ -380,8 +389,7 @@ static void tcp_chr_disconnect(Chardev *chr)
s->listen_tag = qio_channel_add_watch(
QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
}
- chr->filename = SocketAddress_to_str("disconnected:", s->addr,
- s->is_listen, s->is_telnet);
+ update_disconnected_filename(s);
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
if (s->reconnect_time) {
qemu_chr_socket_restart_timer(chr);
@@ -875,8 +883,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
/* be isn't opened until we get a connection */
*be_opened = false;
- chr->filename = SocketAddress_to_str("disconnected:",
- addr, is_listen, is_telnet);
+ update_disconnected_filename(s);
if (is_listen) {
if (is_telnet) {