Hi !

This patch fixes a concurrency issue in shmget02. Same issue as
in shmat02 : second key can conflict with the key from another
process.

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/shmget/shmget02.c
===================================================================
--- cvs.orig/testcases/kernel/syscalls/ipc/shmget/shmget02.c	2008-03-06 18:20:26.000000000 +0100
+++ cvs/testcases/kernel/syscalls/ipc/shmget/shmget02.c	2008-03-06 18:21:27.000000000 +0100
@@ -46,6 +46,10 @@
  * HISTORY
  *	03/2001 - Written by Wayne Boyer
  *
+ *      06/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
  */
@@ -164,7 +168,13 @@
 	/* get an IPC resource key */
 	shmkey = getipckey();
 
-	shmkey2 = shmkey + 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 {
+		shmkey2 = getipckey();
+	} while (shmkey2 == shmkey);
 
 	if ((shm_id_1 = shmget(shmkey, SHM_SIZE, IPC_CREAT | IPC_EXCL |
 	     SHM_RW)) == -1) {

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