Skip to content

Commit

Permalink
Fixes memory errors, broken code, bugs etc
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoppanen committed Feb 6, 2016
1 parent 938f6bc commit a930b41
Show file tree
Hide file tree
Showing 7 changed files with 2,128 additions and 2,217 deletions.
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

0 comments on commit a930b41

Please sign in to comment.