Skip to content

Fix ZTS build #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ memcached extension changelog

Version *******
---------------
* Add OPT_REMOVE_FAILED_SERVERS option.
* Make it work with libmemcached up to 0.49.
* Fix a case where invalid session ID could lock the script.

Version 2.0.0b1
Expand Down
23 changes: 17 additions & 6 deletions php_memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ static void php_memc_destroy(struct memc_obj *m_obj, zend_bool persistent TSRMLS
Method implementations
****************************************/

static zend_bool php_memcached_on_new_callback(zval *object, zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, char *persistent_id, int persistent_id_len)
static zend_bool php_memcached_on_new_callback(zval *object, zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, char *persistent_id, int persistent_id_len TSRMLS_DC)
{
zval pid_z;
zval *retval_ptr, *pid_z_ptr = &pid_z;
Expand Down Expand Up @@ -423,7 +423,7 @@ static PHP_METHOD(Memcached, __construct)
i_obj->is_pristine = 1;

if (ZEND_NUM_ARGS() >= 2) {
if (!php_memcached_on_new_callback(object, &fci, &fci_cache, persistent_id, persistent_id_len) || EG(exception)) {
if (!php_memcached_on_new_callback(object, &fci, &fci_cache, persistent_id, persistent_id_len TSRMLS_CC) || EG(exception)) {
/* error calling or exception thrown from callback */
if (plist_key != NULL) {
efree(plist_key);
Expand Down Expand Up @@ -2441,15 +2441,23 @@ static int php_memc_handle_error(php_memc_t *i_obj, memcached_return status TSRM

case MEMCACHED_SOME_ERRORS:
i_obj->rescode = status;
/* Hnngghgh! */
i_obj->memc_errno = i_obj->obj->memc->cached_errno;
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
i_obj->memc_errno = memcached_last_error_errno(i_obj->obj->memc);
#else
i_obj->memc_errno = i_obj->obj->memc->cached_errno; /* Hnngghgh! */

#endif
result = 0;
break;

default:
i_obj->rescode = status;
/* Hnngghgh! */
i_obj->memc_errno = i_obj->obj->memc->cached_errno;
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
i_obj->memc_errno = memcached_last_error_errno(i_obj->obj->memc);
#else
i_obj->memc_errno = i_obj->obj->memc->cached_errno; /* Hnngghgh! */

#endif
result = -1;
break;
}
Expand Down Expand Up @@ -3383,6 +3391,9 @@ static void php_memc_register_constants(INIT_FUNC_ARGS)
REGISTER_MEMC_CLASS_CONST_LONG(OPT_NUMBER_OF_REPLICAS, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS);
REGISTER_MEMC_CLASS_CONST_LONG(OPT_RANDOMIZE_REPLICA_READ, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ);
#endif
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX >= 0x00049000
REGISTER_MEMC_CLASS_CONST_LONG(OPT_REMOVE_FAILED_SERVERS, MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS);
#endif

/*
* libmemcached result codes
Expand Down