Skip to content

Commit

Permalink
Fix pecl bug #17068, should fix cas restoring.
Browse files Browse the repository at this point in the history
Fixed by moving CAS behavior restoring to immediately
after memcached requests.

Signed-off-by: Andrei Zmievski <andrei@zmievski.org>
  • Loading branch information
tricky authored and andreiz committed May 3, 2010
1 parent 9d019e7 commit ce7866a
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions php_memcached.c
Expand Up @@ -446,6 +446,10 @@ static void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key)

status = memcached_mget_by_key(m_obj->memc, server_key, server_key_len, keys, key_lens, 1);

if (orig_cas_flag == 0) {
memcached_behavior_set(m_obj->memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, orig_cas_flag);
}

if (php_memc_handle_error(i_obj, status TSRMLS_CC) < 0) {
RETURN_FROM_GET;
}
Expand Down Expand Up @@ -497,12 +501,6 @@ static void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key)

memcached_result_free(&result);

/*
* Restore the CAS support flag, but only if we had to turn it on.
*/
if (orig_cas_flag == 0) {
memcached_behavior_set(m_obj->memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, orig_cas_flag);
}
return;

} else {
Expand Down Expand Up @@ -665,10 +663,8 @@ static void php_memc_getMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke
/*
* Restore the CAS support flag, but only if we had to turn it on.
*/
if (cas_tokens) {
if (orig_cas_flag == 0) {
memcached_behavior_set(m_obj->memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, orig_cas_flag);
}
if (cas_tokens && orig_cas_flag == 0) {
memcached_behavior_set(m_obj->memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, orig_cas_flag);
}

efree(mkeys);
Expand Down Expand Up @@ -839,10 +835,8 @@ static void php_memc_getDelayed_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_
/*
* Restore the CAS support flag, but only if we had to turn it on.
*/
if (with_cas) {
if (orig_cas_flag == 0) {
memcached_behavior_set(m_obj->memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, orig_cas_flag);
}
if (with_cas && orig_cas_flag == 0) {
memcached_behavior_set(m_obj->memc, MEMCACHED_BEHAVIOR_SUPPORT_CAS, orig_cas_flag);
}

efree(mkeys);
Expand Down

0 comments on commit ce7866a

Please sign in to comment.