components/php-5_2/APC/patches/04-apc_sem.c.patch
author Craig Mohrman <craig.mohrman@oracle.com>
Fri, 05 Aug 2011 22:11:53 -0700
changeset 461 edabdd6aff23
permissions -rw-r--r--
7072982 move php from sfw to userland consolidation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
461
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     1
--- APC-3.0.19/apc_sem.c.ORIG	Thu Aug 21 17:51:03 2008
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     2
+++ APC-3.0.19/apc_sem.c	Thu Aug 21 17:51:58 2008
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     3
@@ -82,12 +82,16 @@
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     4
         }
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     5
     }
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     6
     
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     7
-    if ((semid = semget(key, 1, IPC_CREAT | IPC_EXCL | perms)) >= 0) {
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     8
+    if ((semid = semget(key, 2, IPC_CREAT | IPC_EXCL | perms)) >= 0) {
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
     9
         /* sempahore created for the first time, initialize now */
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    10
         arg.val = initval;
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    11
         if (semctl(semid, 0, SETVAL, arg) < 0) {
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    12
             apc_eprint("apc_sem_create: semctl(%d,...) failed:", semid);
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    13
         }
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    14
+        arg.val = getpid();
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    15
+        if (semctl(semid, 1, SETVAL, arg) < 0) {
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    16
+            apc_eprint("apc_sem_create: semctl(%d,...) failed:", semid);
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    17
+        }
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    18
     }
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    19
     else if (errno == EEXIST) {
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    20
         /* sempahore already exists, don't initialize */
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    21
@@ -107,7 +111,10 @@
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    22
 {
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    23
     /* we expect this call to fail often, so we do not check */
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    24
     union semun arg;
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    25
-    semctl(semid, 0, IPC_RMID, arg);
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    26
+    int semPid = semctl(semid, 1, GETVAL, 0);
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    27
+    if (semPid == getpid()) {
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    28
+        semctl(semid, 0, IPC_RMID, arg);
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    29
+    }
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    30
 }
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    31
 
edabdd6aff23 7072982 move php from sfw to userland consolidation
Craig Mohrman <craig.mohrman@oracle.com>
parents:
diff changeset
    32
 void apc_sem_lock(int semid)