diff mbox series

[01/10] vhost-user-test: use g_cond_broadcast

Message ID 20181115143124.19234-2-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show
Series vhost: preparation for qgraph conversion of vhost-user-test | expand

Commit Message

Paolo Bonzini Nov. 15, 2018, 2:31 p.m. UTC
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.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/vhost-user-test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Marc-André Lureau Nov. 20, 2018, 8:50 a.m. UTC | #1
On Thu, Nov 15, 2018 at 6:31 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> 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.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  tests/vhost-user-test.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index 45d58d8ea2..656e51938b 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -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:
> --
> 2.19.1
>
>
diff mbox series

Patch

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 45d58d8ea2..656e51938b 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -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: