diff options
author | Dustin Sallings <dustin@spy.net> | 2009-01-21 13:45:25 -0800 |
---|---|---|
committer | Dustin Sallings <dustin@spy.net> | 2009-01-21 13:45:25 -0800 |
commit | 8ff14453be52fb43a1ba5d3fb372847db927530f (patch) | |
tree | 24e342cf5f63b71799b5090d89088c5128a33ba1 /memcached.c | |
parent | 7dcfcedcc4276920ef3a22a090376186bbc5547a (diff) | |
download | memcached-8ff14453be52fb43a1ba5d3fb372847db927530f.tar.gz |
Don't leave stale data on failed set attempt.
On a set that fails to allocate memory, remove any existing value for
the key. Presumably, if a user was attempting to overwrite a cache
entry for whateer reason, that should at the very least be considered
an invalidation.
This catches the binary protocl up to the text wrt
5f54ede879939a160168fabbc8cfc462f28e0004.
Diffstat (limited to 'memcached.c')
-rw-r--r-- | memcached.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/memcached.c b/memcached.c index 286d7e7..0baeb5e 100644 --- a/memcached.c +++ b/memcached.c @@ -1562,6 +1562,17 @@ static void process_bin_update(conn *c) { } else { write_bin_error(c, PROTOCOL_BINARY_RESPONSE_ENOMEM, vlen); } + + /* Avoid stale data persisting in cache because we failed alloc. + * Unacceptable for SET. Anywhere else too? */ + if (c->cmd == PROTOCOL_BINARY_CMD_SET) { + it = item_get(key, nkey); + if (it) { + item_unlink(it); + item_remove(it); + } + } + /* swallow the data line */ c->write_and_go = conn_swallow; return; |