From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdF8w-000255-Cr for qemu-devel@nongnu.org; Sat, 19 Sep 2015 06:13:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdF8v-0005ZB-Gk for qemu-devel@nongnu.org; Sat, 19 Sep 2015 06:13:18 -0400 Received: from mail-qg0-x229.google.com ([2607:f8b0:400d:c04::229]:36094) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdF8v-0005Z7-Da for qemu-devel@nongnu.org; Sat, 19 Sep 2015 06:13:17 -0400 Received: by qgx61 with SMTP id 61so57175857qgx.3 for ; Sat, 19 Sep 2015 03:13:17 -0700 (PDT) Sender: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= From: marcandre.lureau@redhat.com Date: Sat, 19 Sep 2015 12:12:08 +0200 Message-Id: <1442657533-13030-18-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1442657533-13030-1-git-send-email-marcandre.lureau@redhat.com> References: <1442657533-13030-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v4 17/22] vhost-user-test: move wait_for_fds() out List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: haifeng.lin@huawei.com, mst@redhat.com, thibaut.collet@6wind.com, jasowang@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau This function is a precondition for most vhost-user tests. Signed-off-by: Marc-André Lureau --- tests/vhost-user-test.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 228acb6..551a664 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -205,15 +205,11 @@ static GThread *_thread_new(const gchar *name, GThreadFunc func, gpointer data) return thread; } -static void read_guest_mem(void) +static void wait_for_fds(void) { - uint32_t *guest_mem; gint64 end_time; - int i, j; - size_t size; g_mutex_lock(data_mutex); - end_time = _get_time() + 5 * G_TIME_SPAN_SECOND; while (!fds_num) { if (!_cond_wait_until(data_cond, data_mutex, end_time)) { @@ -227,6 +223,17 @@ static void read_guest_mem(void) g_assert_cmpint(fds_num, >, 0); g_assert_cmpint(fds_num, ==, memory.nregions); + g_mutex_unlock(data_mutex); +} + +static void read_guest_mem(void) +{ + uint32_t *guest_mem; + int i, j; + size_t size; + + wait_for_fds(); + /* iterate all regions */ for (i = 0; i < fds_num; i++) { -- 2.4.3