[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v1 3/7] char-socket: initialize reconnect timer only if close
From: |
Dima Stepanov |
Subject: |
[RFC PATCH v1 3/7] char-socket: initialize reconnect timer only if close is emitted |
Date: |
Thu, 23 Apr 2020 21:39:34 +0300 |
During vhost-user reconnect functionality testing the following assert
was hit:
qemu-system-x86_64: chardev/char-socket.c:125:
qemu_chr_socket_restart_timer: Assertion `!s->reconnect_timer' failed.
Aborted (core dumped)
This is observed only if the connection is closed by the vhost-user-blk
daemon during the initialization routine. In this case the
tcp_chr_disconnect_locked() routine is called twice. First time it is
called in the tcp_chr_write() routine, after getting the SIGPIPE signal.
Second time it is called when vhost_user_blk_connect() routine return
error. In general it looks correct, because the initialization routine
can return error in many cases.
The tcp_chr_disconnect_locked() routine could be fixed. The timer will
be restarted only if the close event is emitted.
Signed-off-by: Dima Stepanov <address@hidden>
---
chardev/char-socket.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index c128cca..83ca4d9 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -476,7 +476,7 @@ static void update_disconnected_filename(SocketChardev *s)
static void tcp_chr_disconnect_locked(Chardev *chr)
{
SocketChardev *s = SOCKET_CHARDEV(chr);
- bool emit_close = s->state == TCP_CHARDEV_STATE_CONNECTED;
+ bool was_connected = s->state == TCP_CHARDEV_STATE_CONNECTED;
tcp_chr_free_connection(chr);
@@ -485,11 +485,11 @@ static void tcp_chr_disconnect_locked(Chardev *chr)
chr, NULL, chr->gcontext);
}
update_disconnected_filename(s);
- if (emit_close) {
+ if (was_connected) {
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
- }
- if (s->reconnect_time) {
- qemu_chr_socket_restart_timer(chr);
+ if (s->reconnect_time) {
+ qemu_chr_socket_restart_timer(chr);
+ }
}
}
--
2.7.4
[RFC PATCH v1 2/7] char-socket: return -1 in case of disconnect during tcp_chr_write, Dima Stepanov, 2020/04/23
[RFC PATCH v1 4/7] vhost: introduce wrappers to set guest notifiers for virtio device, Dima Stepanov, 2020/04/23
[RFC PATCH v1 5/7] vhost-user-blk: add mechanism to track the guest notifiers init state, Dima Stepanov, 2020/04/23
[RFC PATCH v1 6/7] vhost: check vring address before calling unmap, Dima Stepanov, 2020/04/23