Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lakil-0000a3-N0 for qemu-devel@nongnu.org; Sat, 21 Feb 2009 00:48:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lakil-0000Zo-9Z for qemu-devel@nongnu.org; Sat, 21 Feb 2009 00:48:15 -0500 Received: from [199.232.76.173] (port=55311 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lakil-0000Zj-0k for qemu-devel@nongnu.org; Sat, 21 Feb 2009 00:48:15 -0500 Received: from savannah.gnu.org ([199.232.41.3]:33725 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lakik-0006pO-Ly for qemu-devel@nongnu.org; Sat, 21 Feb 2009 00:48:14 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Lakik-0006Mg-80 for qemu-devel@nongnu.org; Sat, 21 Feb 2009 05:48:14 +0000 Received: from malc by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Lakik-0006Mc-1I for qemu-devel@nongnu.org; Sat, 21 Feb 2009 05:48:14 +0000 MIME-Version: 1.0 Errors-To: malc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: malc Message-Id: Date: Sat, 21 Feb 2009 05:48:14 +0000 Subject: [Qemu-devel] [6631] Avoid infinite loop around timed condition variable Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6631 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6631 Author: malc Date: 2009-02-21 05:48:13 +0000 (Sat, 21 Feb 2009) Log Message: ----------- Avoid infinite loop around timed condition variable This can happen due to spurious wakeups Modified Paths: -------------- trunk/posix-aio-compat.c Modified: trunk/posix-aio-compat.c =================================================================== --- trunk/posix-aio-compat.c 2009-02-21 05:48:11 UTC (rev 6630) +++ trunk/posix-aio-compat.c 2009-02-21 05:48:13 UTC (rev 6631) @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -86,16 +86,17 @@ struct qemu_paiocb *aiocb; size_t offset; int ret = 0; + qemu_timeval tv; + struct timespec ts; + qemu_gettimeofday(&tv); + ts.tv_sec = tv.tv_sec + 10; + ts.tv_nsec = 0; + mutex_lock(&lock); while (TAILQ_EMPTY(&request_list) && !(ret == ETIMEDOUT)) { - struct timespec ts = { 0 }; - qemu_timeval tv; - - qemu_gettimeofday(&tv); - ts.tv_sec = tv.tv_sec + 10; ret = cond_timedwait(&cond, &lock, &ts); }