Hi !

Here is a patch fixing a concurrency issue in semop02.c.
The now, well known issue due to a second key badly created.

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/semop/semop02.c
===================================================================
--- cvs.orig/testcases/kernel/syscalls/ipc/semop/semop02.c	2008-03-10 14:56:54.000000000 +0100
+++ cvs/testcases/kernel/syscalls/ipc/semop/semop02.c	2008-03-10 15:01:21.000000000 +0100
@@ -47,6 +47,10 @@
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *
+ *      10/03/2008 Renaud Lottiaux ([EMAIL PROTECTED])
+ *      - Fix concurrency issue. The second key used for this test could
+ *        conflict with the key from another task.
+ *
  * RESTRICTIONS
  *	none
  */
@@ -153,6 +157,8 @@
 void
 setup(void)
 {
+	key_t semkey2;
+
 	/* Switch to nobody user for correct error code collection */
         if (geteuid() != 0) {
                 tst_brkm(TBROK, tst_exit, "Test must be run as root");
@@ -191,11 +197,16 @@
 		tst_brkm(TBROK, cleanup, "couldn't create semaphore in setup");
 	}
 
-	/* increment the semkey */
-	semkey += 1;
+	/* Get an new IPC resource key. Since there is a small chance the
+	 * getipckey() function returns the same key as the previous one,
+	 * loop until we have a different key.
+	 */
+	do {
+		semkey2 = getipckey();
+	} while (semkey2 == semkey);
 	
 	/* create a semaphore set without read and alter permissions */
-	if ((sem_id_2 = semget(semkey, PSEMS, IPC_CREAT | IPC_EXCL)) == -1) {
+	if ((sem_id_2 = semget(semkey2, PSEMS, IPC_CREAT | IPC_EXCL)) == -1) {
 		tst_brkm(TBROK, cleanup, "couldn't create semaphore in setup");
 	}
 }

Attachment: signature.asc
Description: This is a digitally signed message part.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to