Skip to content
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

Fixes memory errors, broken code, bugs etc #214

Merged
merged 1 commit into from
Feb 9, 2016
Merged
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
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ API
* Fixes error where cache callback for get command was not setting expiration time properly
* Added server type to server list
* Remove use_sasl ini-variable and initialise sasl as needed
* CAS tokens are returned as integers and in case of too large values they overflow to strings

Session handler
* Session lock algorithm updated (new ini-values memcached.sess_lock_wait_min, memcached.sess_lock_wait_max and memcached.sess_lock_retries)
Expand Down
40 changes: 12 additions & 28 deletions php_libmemcached_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,20 @@
#include "php_memcached_private.h"
#include "php_libmemcached_compat.h"

memcached_st *php_memc_create_str (const char *str, size_t str_len)
memcached_return php_memcached_exist (memcached_st *memc, zend_string *key)
{
#ifdef HAVE_LIBMEMCACHED_MEMCACHED
return memcached (str, str_len);
#ifdef HAVE_MEMCACHED_EXIST
return memcached_exist (memc, key->val, key->len);
#else
memcached_return rc;
memcached_st *memc;
memcached_server_st *servers;

memc = memcached_create(NULL);

if (!memc) {
return NULL;
}

servers = memcached_servers_parse (str);

if (!servers) {
memcached_free (memc);
return NULL;
memcached_return rc = MEMCACHED_SUCCESS;
uint32_t flags = 0;
size_t value_length = 0;
char *value = NULL;

value = memcached_get (memc, key->val, key->len, &value_length, &flags, &rc);
if (value) {
free (value);
}

rc = memcached_server_push (memc, servers);
memcached_server_free (servers);

if (rc != MEMCACHED_SUCCESS) {
memcached_free (memc);
return NULL;
}
return memc;
return rc;
#endif
}

2 changes: 1 addition & 1 deletion php_libmemcached_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/* this is the version(s) we support */
#include <libmemcached/memcached.h>

memcached_st *php_memc_create_str (const char *str, size_t str_len);
memcached_return php_memcached_exist (memcached_st *memc, zend_string *key);

#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x00052000
# define MEMCACHED_SERVER_TEMPORARILY_DISABLED (1024 << 2)
Expand Down
Loading