OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 #ifndef __SSLMUTEX_H_ | 4 #ifndef __SSLMUTEX_H_ |
5 #define __SSLMUTEX_H_ 1 | 5 #define __SSLMUTEX_H_ 1 |
6 | 6 |
7 /* What SSL really wants is portable process-shared unnamed mutexes in | 7 /* What SSL really wants is portable process-shared unnamed mutexes in |
8 * shared memory, that have the property that if the process that holds | 8 * shared memory, that have the property that if the process that holds |
9 * them dies, they are released automatically, and that (unlike fcntl | 9 * them dies, they are released automatically, and that (unlike fcntl |
10 * record locking) lock to the thread, not to the process. | 10 * record locking) lock to the thread, not to the process. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 union { | 60 union { |
61 PRLock* sslLock; | 61 PRLock* sslLock; |
62 struct { | 62 struct { |
63 int mPipes[3]; | 63 int mPipes[3]; |
64 PRInt32 nWaiters; | 64 PRInt32 nWaiters; |
65 } pipeStr; | 65 } pipeStr; |
66 } u; | 66 } u; |
67 } sslMutex; | 67 } sslMutex; |
68 typedef pid_t sslPID; | 68 typedef pid_t sslPID; |
69 | 69 |
70 #elif defined(XP_UNIX) /* other types of Unix */ | 70 /* other types of unix, except OS X */ |
| 71 #elif defined(XP_UNIX) && !defined(DARWIN) |
71 | 72 |
72 #include <sys/types.h> /* for pid_t */ | 73 #include <sys/types.h> /* for pid_t */ |
73 #include <semaphore.h> /* for sem_t, and sem_* functions */ | 74 #include <semaphore.h> /* for sem_t, and sem_* functions */ |
74 | 75 |
75 typedef struct | 76 typedef struct |
76 { | 77 { |
77 PRBool isMultiProcess; | 78 PRBool isMultiProcess; |
78 union { | 79 union { |
79 PRLock* sslLock; | 80 PRLock* sslLock; |
80 sem_t sem; | 81 sem_t sem; |
81 } u; | 82 } u; |
82 } sslMutex; | 83 } sslMutex; |
83 | 84 |
84 typedef pid_t sslPID; | 85 typedef pid_t sslPID; |
85 | 86 |
86 #else | 87 #else /* no support for cross-process locking */ |
87 | 88 |
88 /* what platform is this ?? */ | 89 /* what platform is this ?? */ |
89 | 90 |
90 typedef struct { | 91 typedef struct { |
91 PRBool isMultiProcess; | 92 PRBool isMultiProcess; |
92 union { | 93 union { |
93 PRLock* sslLock; | 94 PRLock* sslLock; |
94 /* include cross-process locking mechanism here */ | 95 /* include cross-process locking mechanism here */ |
95 } u; | 96 } u; |
96 } sslMutex; | 97 } sslMutex; |
97 | 98 |
| 99 #ifdef DARWIN |
| 100 typedef pid_t sslPID; |
| 101 #else |
98 typedef int sslPID; | 102 typedef int sslPID; |
| 103 #endif |
99 | 104 |
100 #endif | 105 #endif |
101 | 106 |
102 #include "seccomon.h" | 107 #include "seccomon.h" |
103 | 108 |
104 SEC_BEGIN_PROTOS | 109 SEC_BEGIN_PROTOS |
105 | 110 |
106 extern SECStatus sslMutex_Init(sslMutex *sem, int shared); | 111 extern SECStatus sslMutex_Init(sslMutex *sem, int shared); |
107 | 112 |
108 /* If processLocal is set to true, then just free resources which are *only* ass
ociated | 113 /* If processLocal is set to true, then just free resources which are *only* ass
ociated |
109 * with the current process. Leave any shared resources (including the state of | 114 * with the current process. Leave any shared resources (including the state of |
110 * shared memory) intact. */ | 115 * shared memory) intact. */ |
111 extern SECStatus sslMutex_Destroy(sslMutex *sem, PRBool processLocal); | 116 extern SECStatus sslMutex_Destroy(sslMutex *sem, PRBool processLocal); |
112 | 117 |
113 extern SECStatus sslMutex_Unlock(sslMutex *sem); | 118 extern SECStatus sslMutex_Unlock(sslMutex *sem); |
114 | 119 |
115 extern SECStatus sslMutex_Lock(sslMutex *sem); | 120 extern SECStatus sslMutex_Lock(sslMutex *sem); |
116 | 121 |
117 #ifdef WINNT | 122 #ifdef WINNT |
118 | 123 |
119 extern SECStatus sslMutex_2LevelInit(sslMutex *sem); | 124 extern SECStatus sslMutex_2LevelInit(sslMutex *sem); |
120 | 125 |
121 #endif | 126 #endif |
122 | 127 |
123 SEC_END_PROTOS | 128 SEC_END_PROTOS |
124 | 129 |
125 #endif | 130 #endif |
OLD | NEW |