From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lakiq-0000dD-QR for qemu-devel@nongnu.org; Sat, 21 Feb 2009 00:48:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lakip-0000c2-IS for qemu-devel@nongnu.org; Sat, 21 Feb 2009 00:48:20 -0500 Received: from [199.232.76.173] (port=55315 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lakio-0000bj-W7 for qemu-devel@nongnu.org; Sat, 21 Feb 2009 00:48:19 -0500 Received: from savannah.gnu.org ([199.232.41.3]:33731 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 1Lakio-0006q4-N9 for qemu-devel@nongnu.org; Sat, 21 Feb 2009 00:48:18 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1Lakio-0006NA-95 for qemu-devel@nongnu.org; Sat, 21 Feb 2009 05:48:18 +0000 Received: from malc by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1Lakio-0006N6-4k for qemu-devel@nongnu.org; Sat, 21 Feb 2009 05:48:18 +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:18 +0000 Subject: [Qemu-devel] [6633] Cosmetics 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: 6633 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6633 Author: malc Date: 2009-02-21 05:48:17 +0000 (Sat, 21 Feb 2009) Log Message: ----------- Cosmetics Avoid repeated creation/initalization/destruction of attr and calls to getpid Modified Paths: -------------- trunk/posix-aio-compat.c Modified: trunk/posix-aio-compat.c =================================================================== --- trunk/posix-aio-compat.c 2009-02-21 05:48:15 UTC (rev 6632) +++ trunk/posix-aio-compat.c 2009-02-21 05:48:17 UTC (rev 6633) @@ -25,6 +25,7 @@ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static pthread_t thread_id; +static pthread_attr_t attr; static int max_threads = 64; static int cur_threads = 0; static int idle_threads = 0; @@ -76,8 +77,11 @@ static void *aio_thread(void *unused) { + pid_t pid; sigset_t set; + pid = getpid(); + /* block all signals */ if (sigfillset(&set)) die("sigfillset"); if (sigprocmask(SIG_BLOCK, &set, NULL)) die("sigprocmask"); @@ -142,7 +146,7 @@ idle_threads++; mutex_unlock(&lock); - if (kill(getpid(), aiocb->ev_signo)) die("kill failed"); + if (kill(pid, aiocb->ev_signo)) die("kill failed"); } idle_threads--; @@ -154,23 +158,21 @@ static void spawn_thread(void) { - int ret; - pthread_attr_t attr; - cur_threads++; idle_threads++; - - ret = pthread_attr_init(&attr); - if (ret) die2 (ret, "pthread_attr_init"); - ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - if (ret) die2 (ret, "pthread_attr_setdetachstate"); thread_create(&thread_id, &attr, aio_thread, NULL); - ret = pthread_attr_destroy(&attr); - if (ret) die2 (ret, "pthread_attr_destroy"); } int qemu_paio_init(struct qemu_paioinit *aioinit) { + int ret; + + ret = pthread_attr_init(&attr); + if (ret) die2(ret, "pthread_attr_init"); + + ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + if (ret) die2(ret, "pthread_attr_setdetachstate"); + TAILQ_INIT(&request_list); return 0;