Skip to content

Commit

Permalink
Merge pull request #304 from dyeldandi/REL2_0
Browse files Browse the repository at this point in the history
REL2_0 pull request, replacement for pull requests #282 and #165
  • Loading branch information
sodabrew authored Jan 25, 2017
2 parents de6b9b5 + bf8d61d commit ee95725
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions php_memcached_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,6 @@ PS_OPEN_FUNC(memcached)
status = memcached_server_push(memc_sess->memc_sess, servers);
memcached_server_list_free(servers);

if (MEMC_G(sess_prefix) && MEMC_G(sess_prefix)[0] != 0 && memcached_callback_set(memc_sess->memc_sess, MEMCACHED_CALLBACK_PREFIX_KEY, MEMC_G(sess_prefix)) != MEMCACHED_SUCCESS) {
PS_SET_MOD_DATA(NULL);
if (plist_key) {
efree(plist_key);
}
memcached_free(memc_sess->memc_sess);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "bad memcached key prefix in memcached.sess_prefix");
return FAILURE;
}

if (status == MEMCACHED_SUCCESS) {
goto success;
}
Expand Down Expand Up @@ -211,6 +201,13 @@ PS_OPEN_FUNC(memcached)
return FAILURE;
}
}

if (MEMC_G(sess_prefix) && MEMC_G(sess_prefix)[0] != 0 ) {
if (memcached_callback_set(memc_sess->memc_sess, MEMCACHED_CALLBACK_PREFIX_KEY, MEMC_G(sess_prefix)) != MEMCACHED_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "bad memcached key prefix in memcached.sess_prefix");
return FAILURE;
}
}
#ifdef HAVE_MEMCACHED_SASL
if (MEMC_G(use_sasl)) {
/*
Expand Down Expand Up @@ -331,7 +328,11 @@ PS_READ_FUNC(memcached)
*vallen = payload_len;
free(payload);
return SUCCESS;
} else if (status == MEMCACHED_NOTFOUND) {
/* this is okey, session may not be in memcached yet */
return FAILURE;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "error getting session from memcached: %s", memcached_last_error_message(memc_sess->memc_sess));
return FAILURE;
}
}
Expand Down Expand Up @@ -371,6 +372,7 @@ PS_WRITE_FUNC(memcached)
if (status == MEMCACHED_SUCCESS) {
return SUCCESS;
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "error saving session to memcached: %s", memcached_last_error_message(memc_sess->memc_sess));
write_try_attempts--;
}
} while (write_try_attempts > 0);
Expand Down

0 comments on commit ee95725

Please sign in to comment.