Permalink
Browse files

More fixes on #59

  • Loading branch information...
1 parent 25414ce commit 3c4ae7c0ea6f94980266d09d98f0e025506755e1 @mkoppanen committed Jul 9, 2012
Showing with 7 additions and 1 deletion.
  1. +3 −0 php_zmq_private.h
  2. +4 −1 zmq.c
View
@@ -102,6 +102,9 @@ typedef struct _php_zmq_socket {
HashTable bind;
zend_bool is_persistent;
+
+ /* Who created me */
+ int pid;
} php_zmq_socket;
/* }}} */
View
5 zmq.c
@@ -113,7 +113,9 @@ static void php_zmq_socket_destroy(php_zmq_socket *zmq_sock)
zend_hash_destroy(&(zmq_sock->connect));
zend_hash_destroy(&(zmq_sock->bind));
- (void) zmq_close(zmq_sock->z_socket);
+ if (zmq_sock->pid == getpid ())
+ (void) zmq_close(zmq_sock->z_socket);
+
pefree(zmq_sock, zmq_sock->is_persistent);
}
/* }}} */
@@ -219,6 +221,7 @@ static php_zmq_socket *php_zmq_socket_new(php_zmq_context *context, int type, ze
zmq_sock = pecalloc(1, sizeof(php_zmq_socket), is_persistent);
zmq_sock->z_socket = zmq_socket(context->z_ctx, type);
+ zmq_sock->pid = getpid();
if (!zmq_sock->z_socket) {
pefree(zmq_sock, is_persistent);

0 comments on commit 3c4ae7c

Please sign in to comment.