Skip to content

Commit a930b41

Browse files
committed
Fixes memory errors, broken code, bugs etc
1 parent 938f6bc commit a930b41

7 files changed

+2128
-2217
lines changed

package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ API
202202
* Fixes error where cache callback for get command was not setting expiration time properly
203203
* Added server type to server list
204204
* Remove use_sasl ini-variable and initialise sasl as needed
205+
* CAS tokens are returned as integers and in case of too large values they overflow to strings
205206

206207
Session handler
207208
* Session lock algorithm updated (new ini-values memcached.sess_lock_wait_min, memcached.sess_lock_wait_max and memcached.sess_lock_retries)

php_libmemcached_compat.c

+12-28
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,20 @@
1818
#include "php_memcached_private.h"
1919
#include "php_libmemcached_compat.h"
2020

21-
memcached_st *php_memc_create_str (const char *str, size_t str_len)
21+
memcached_return php_memcached_exist (memcached_st *memc, zend_string *key)
2222
{
23-
#ifdef HAVE_LIBMEMCACHED_MEMCACHED
24-
return memcached (str, str_len);
23+
#ifdef HAVE_MEMCACHED_EXIST
24+
return memcached_exist (memc, key->val, key->len);
2525
#else
26-
memcached_return rc;
27-
memcached_st *memc;
28-
memcached_server_st *servers;
29-
30-
memc = memcached_create(NULL);
31-
32-
if (!memc) {
33-
return NULL;
34-
}
35-
36-
servers = memcached_servers_parse (str);
37-
38-
if (!servers) {
39-
memcached_free (memc);
40-
return NULL;
26+
memcached_return rc = MEMCACHED_SUCCESS;
27+
uint32_t flags = 0;
28+
size_t value_length = 0;
29+
char *value = NULL;
30+
31+
value = memcached_get (memc, key->val, key->len, &value_length, &flags, &rc);
32+
if (value) {
33+
free (value);
4134
}
42-
43-
rc = memcached_server_push (memc, servers);
44-
memcached_server_free (servers);
45-
46-
if (rc != MEMCACHED_SUCCESS) {
47-
memcached_free (memc);
48-
return NULL;
49-
}
50-
return memc;
35+
return rc;
5136
#endif
5237
}
53-

php_libmemcached_compat.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/* this is the version(s) we support */
2121
#include <libmemcached/memcached.h>
2222

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

2525
#if defined(LIBMEMCACHED_VERSION_HEX) && LIBMEMCACHED_VERSION_HEX < 0x00052000
2626
# define MEMCACHED_SERVER_TEMPORARILY_DISABLED (1024 << 2)

0 commit comments

Comments
 (0)