]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix initialization of optimization values for AIO
authorUlrich Drepper <drepper@gmail.com>
Sat, 14 May 2011 23:30:37 +0000 (00:30 +0100)
committerPetr Baudis <pasky@ucw.cz>
Thu, 26 May 2011 23:33:47 +0000 (01:33 +0200)
(cherry picked from commit 2fc54d6f9f7d6770ecb0e0bb5a3b977965bfe273)

ChangeLog
sysdeps/pthread/aio_misc.c

index 8fcbbbb780d4ccf021051d1d1300ef1b9c32b473..884b21e766b365fa4084b8050faa45345f56ec20 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-05-14  Ulrich Drepper  <drepper@gmail.com>
 
+       [BZ #12083]
+       * sysdeps/pthread/aio_misc.c (__aio_init): Compute optim.aio_num
+       correctly.
+
        * libio/fileops.c (_IO_new_file_close_it): Initialize write_status.
 
        * iconv/loop.c (SINGLE) [STORE_REST]: Add input bytes to bytebuf before
index c82acbbc2d0c0cabbbe61d7b7b6d550fc55598c0..ca3d1111e85939b537254ac726b93304de49866f 100644 (file)
@@ -1,5 +1,5 @@
 /* Handle general operations.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006, 2007, 2009
+   Copyright (C) 1997-2001, 2003, 2004, 2006, 2007, 2009, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -26,6 +26,7 @@
 #include <pthread.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <aio_misc.h>
@@ -87,7 +88,7 @@ static int idle_thread_count;
 static struct aioinit optim =
 {
   20,  /* int aio_threads;     Maximal number of threads.  */
-  64,  /* int aio_num;         Number of expected simultanious requests. */
+  64,  /* int aio_num;         Number of expected simultaneous requests. */
   0,
   0,
   0,
@@ -282,9 +283,10 @@ __aio_init (const struct aioinit *init)
   if (pool == NULL)
     {
       optim.aio_threads = init->aio_threads < 1 ? 1 : init->aio_threads;
+      assert (powerof2 (ENTRIES_PER_ROW));
       optim.aio_num = (init->aio_num < ENTRIES_PER_ROW
                       ? ENTRIES_PER_ROW
-                      : init->aio_num & ~ENTRIES_PER_ROW);
+                      : init->aio_num & ~(ENTRIES_PER_ROW - 1));
     }
 
   if (init->aio_idle_time != 0)