summaryrefslogtreecommitdiff
path: root/tests/vhost-user-test.c
diff options
context:
space:
mode:
authorNikolay Nikolaev <n.nikolaev@virtualopensystems.com>2014-06-19 18:08:18 +0300
committerMichael S. Tsirkin <mst@redhat.com>2014-06-23 17:37:59 +0300
commitf61badf32f1870e80e579f9dac363891a226e976 (patch)
tree8550271cfd28592e530c552a7af003cce78bb9e3 /tests/vhost-user-test.c
parentbd95939fc804f3a6ffddbe761cdb21421808f156 (diff)
downloadqemu-f61badf32f1870e80e579f9dac363891a226e976.tar.gz
qtest: fix vhost-user-test unbalanced mutex locks
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'tests/vhost-user-test.c')
-rw-r--r--tests/vhost-user-test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 2934379d90..2af2381a1d 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -269,6 +269,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
return;
}
+ g_mutex_lock(data_mutex);
memcpy(p, buf, VHOST_USER_HDR_SIZE);
if (msg.size) {
@@ -302,7 +303,6 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
/* signal the test that it can continue */
g_cond_signal(data_cond);
- g_mutex_unlock(data_mutex);
break;
case VHOST_USER_SET_VRING_KICK:
@@ -319,6 +319,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)
default:
break;
}
+ g_mutex_unlock(data_mutex);
}
static const char *init_hugepagefs(void)
@@ -385,7 +386,6 @@ int main(int argc, char **argv)
/* run the main loop thread so the chardev may operate */
data_mutex = _mutex_new();
data_cond = _cond_new();
- g_mutex_lock(data_mutex);
_thread_new(NULL, thread_function, NULL);
qemu_cmd = g_strdup_printf(QEMU_CMD, hugefs, socket_path);