Hi ! This patch fix a concurrency issue in semctl06. The IPC keys used for this test could conflict with keys from another task.
Signed-off-by: Matthieu Fertré <[EMAIL PROTECTED]> R. -- Renaud Lottiaux Kerlabs Bâtiment Germanium 80, avenue des buttes de Coësmes 35700 Rennes - France Phone : (+33|0)6 80 89 19 34 Fax : (+33|0)2 99 84 71 71 Email : [EMAIL PROTECTED] Web : http://www.kerlabs.com/
Index: cvs/testcases/kernel/syscalls/ipc/semctl/semctl06.c =================================================================== --- cvs.orig/testcases/kernel/syscalls/ipc/semctl/semctl06.c 2008-06-02 17:13:29.000000000 +0200 +++ cvs/testcases/kernel/syscalls/ipc/semctl/semctl06.c 2008-06-17 16:45:17.000000000 +0200 @@ -17,10 +17,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* 06/30/2001 Port to Linux [EMAIL PROTECTED] */ -/* 10/30/2002 Port to LTP [EMAIL PROTECTED] */ - - /* * NAME * semctl06 @@ -37,6 +33,13 @@ * If this test fail, it may be necessary to use the ipcs and ipcrm * commands to remove any semaphores left in the system due to a * premature exit of this test. + * + * HISTORY + * 06/30/2001 Port to Linux [EMAIL PROTECTED] + * 10/30/2002 Port to LTP [EMAIL PROTECTED] + * 12/03/2008 Matthieu Fertré ([EMAIL PROTECTED]) + * - Fix concurrency issue. The IPC keys used for this test could + * conflict with keys from another task. */ #define DEBUG 0 @@ -111,7 +114,7 @@ int main(int argc, char **argv) { - register int i, j, ok, pid; + register int i, pid; int count, child, status, nwait; #ifdef UCLINUX @@ -128,26 +131,10 @@ nwait = 0; setup(); /*--------------------------------------------------------------*/ - srand(getpid()); - tid = -1; - for (i = 0; i < NPROCS; i++) { - do { - keyarray[i] = (key_t)rand(); - if (keyarray[i] == IPC_PRIVATE) { - ok = 0; - continue; - } - ok = 1; - for (j = 0; j < i; j++) { - if (keyarray[j] == keyarray[i]) { - ok = 0; - break; - } - } - } while (ok == 0); - } + for (i = 0; i < NPROCS; i++) + keyarray[i] = getipckey(); if ((signal(SIGTERM, term)) == SIG_ERR) { tst_resm(TFAIL, "\tsignal failed. errno = %d", errno); @@ -214,7 +201,7 @@ nwait = 0; srand(getpid()); - if ((id = semget(key, NSEMS, IPC_CREAT)) < 0) { + if ((id = semget(key, NSEMS, IPC_CREAT|IPC_EXCL)) < 0) { tst_resm(TFAIL, "\tsemget() failed errno %d", errno); exit(1); } @@ -436,6 +423,13 @@ * before you create your temporary directory. */ TEST_PAUSE; + + /* + * Create a temporary directory and cd into it. + * This helps to ensure that a unique msgkey is created. + * See ../lib/libipc.c for more information. + */ + tst_tmpdir(); } @@ -446,6 +440,9 @@ void cleanup() { + /* Remove the temporary directory */ + tst_rmdir(); + /* * print timing stats if that option was specified. * print errno log if that option was specified.
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php
_______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list