Skip to content

Commit f1300a2

Browse files
committed
PHP-144 - Persistent sessions reference counting issue
Fixed issue where persistent sessions were incorrectly double decrementing the reference count; Once when deleting from the hash and once in the persistent session dtor.
1 parent 7e644f1 commit f1300a2

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

ext/src/DefaultCluster.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ PHP_METHOD(DefaultCluster, connect)
117117

118118
if (php_driver_future_is_error(future TSRMLS_CC) == FAILURE) {
119119
if (session->persist) {
120-
if (PHP5TO7_ZEND_HASH_DEL(&EG(persistent_list), hash_key, hash_key_len + 1)) {
121-
// TODO: Is this correct?
122-
php_driver_del_peref(&session->session, 1);
123-
}
124-
120+
PHP5TO7_ZEND_HASH_DEL(&EG(persistent_list), hash_key, hash_key_len + 1);
125121
efree(hash_key);
126122
} else {
127123
cass_future_free(future);

ext/src/FutureSession.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ PHP_METHOD(FutureSession, get)
3535

3636
self = PHP_DRIVER_GET_FUTURE_SESSION(getThis());
3737

38+
if (self->exception_message) {
39+
zend_throw_exception_ex(exception_class(self->exception_code),
40+
self->exception_code TSRMLS_CC, self->exception_message);
41+
return;
42+
}
43+
3844
if (!PHP5TO7_ZVAL_IS_UNDEF(self->default_session)) {
3945
RETURN_ZVAL(PHP5TO7_ZVAL_MAYBE_P(self->default_session), 1, 0);
4046
}
@@ -45,12 +51,6 @@ PHP_METHOD(FutureSession, get)
4551
session->session = php_driver_add_ref(self->session);
4652
session->persist = self->persist;
4753

48-
if (self->exception_message) {
49-
zend_throw_exception_ex(exception_class(self->exception_code),
50-
self->exception_code TSRMLS_CC, self->exception_message);
51-
return;
52-
}
53-
5454
if (php_driver_future_wait_timed(self->future, timeout TSRMLS_CC) == FAILURE) {
5555
return;
5656
}
@@ -67,8 +67,6 @@ PHP_METHOD(FutureSession, get)
6767
self->exception_code = rc;
6868

6969
if (PHP5TO7_ZEND_HASH_DEL(&EG(persistent_list), self->hash_key, self->hash_key_len + 1)) {
70-
// TODO: Is this right?
71-
php_driver_del_peref(&self->session, 1);
7270
self->future = NULL;
7371
}
7472

0 commit comments

Comments
 (0)