]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
qtest: fix vhost-user-test unbalanced mutex locks
authorNikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Thu, 19 Jun 2014 15:08:18 +0000 (18:08 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 23 Jun 2014 14:37:59 +0000 (17:37 +0300)
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>
tests/vhost-user-test.c

index 2934379d90acf5a383312c6b359a89b539daf780..2af2381a1de7829fd84d3b8bfd4aeff3b8ff5b8c 100644 (file)
@@ -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);