File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,9 @@ static
100
100
static
101
101
zend_long s_ctx_socket_count = 0 ;
102
102
103
+ static
104
+ int s_ctx_pid = 0 ;
105
+
103
106
#ifdef ZTS
104
107
static
105
108
MUTEX_T s_ctx_mutex ;
@@ -109,6 +112,7 @@ int s_shared_ctx_init()
109
112
{
110
113
if (!s_ctx ) {
111
114
s_ctx_mutex = tsrm_mutex_alloc ();
115
+ s_ctx_pid = getpid ();
112
116
s_ctx = zmq_init (PHP_ZMQ_SHARED_CONTEXT_THREADS );
113
117
}
114
118
return (s_ctx != NULL );
@@ -131,11 +135,14 @@ void s_shared_ctx_unlock()
131
135
static
132
136
void s_shared_ctx_destroy ()
133
137
{
134
- if (s_ctx ) {
135
- zmq_term (s_ctx );
138
+ if (s_ctx && s_ctx_pid == getpid ()) {
139
+ s_shared_ctx_lock ();
140
+ {
141
+ zmq_term (s_ctx );
142
+ s_ctx = NULL ;
143
+ }
144
+ s_shared_ctx_unlock ()
136
145
tsrm_mutex_free (s_ctx_mutex );
137
-
138
- s_ctx = NULL ;
139
146
s_ctx_mutex = NULL ;
140
147
}
141
148
}
@@ -144,6 +151,7 @@ static
144
151
int s_shared_ctx_init ()
145
152
{
146
153
s_ctx = zmq_init (PHP_ZMQ_SHARED_CONTEXT_THREADS );
154
+ s_ctx_pid = getpid ();
147
155
return (s_ctx != NULL );
148
156
}
149
157
@@ -153,7 +161,9 @@ static void s_shared_ctx_unlock() {}
153
161
static
154
162
void s_shared_ctx_destroy ()
155
163
{
156
- zmq_term (s_ctx );
164
+ if (s_ctx && s_ctx_pid == getpid ()) {
165
+ zmq_term (s_ctx );
166
+ }
157
167
}
158
168
#endif
159
169
You can’t perform that action at this time.
0 commit comments