vhost-user-test: use g_cond_broadcast
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 3 Dec 2018 15:32:19 +0000 (16:32 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 5 Feb 2019 15:48:40 +0000 (16:48 +0100)
g_cond_signal is rarely the right thing to do, it works now because
vhost-user-test only has two threads but it is not correct in general.
Fix it before adding more calls.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <1543851204-41186-7-git-send-email-pbonzini@redhat.com>

tests/vhost-user-test.c

index 84e50d84e71caf808e0af3786649454e8f3d7802..9baaff4f24b3019358ec9cacab621f002f592dfb 100644 (file)
@@ -393,7 +393,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
                                             G_N_ELEMENTS(s->fds));
 
         /* signal the test that it can continue */
-        g_cond_signal(&s->data_cond);
+        g_cond_broadcast(&s->data_cond);
         break;
 
     case VHOST_USER_SET_VRING_KICK:
@@ -419,7 +419,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
         p = (uint8_t *) &msg;
         qemu_chr_fe_write_all(chr, p, VHOST_USER_HDR_SIZE);
 
-        g_cond_signal(&s->data_cond);
+        g_cond_broadcast(&s->data_cond);
         break;
 
     case VHOST_USER_SET_VRING_BASE: