Changeset 608
- Timestamp:
- 08/22/07 04:03:01 (1 year ago)
- Files:
-
- trunk/server/ChangeLog (modified) (1 diff)
- trunk/server/doc/protocol.txt (modified) (1 diff)
- trunk/server/memcached.c (modified) (4 diffs)
- trunk/server/t/incrdecr.t (modified) (3 diffs)
- trunk/server/thread.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/server/ChangeLog
r606 r608 1 2007-08-21 Paul Lindner <lindner@inuus.com> 2 * Incorporate incrememnt patch from Evan Miller 3 <emiller@imvu.com> to define increment overflow 4 behavior. 5 1 6 2007-08-07 Leon Brocard <acme@astray.com> 2 7 * Bring the memcached.1 manpage up to date trunk/server/doc/protocol.txt
r575 r608 280 280 281 281 Note that underflow in the "decr" command is caught: if a client tries 282 to decrease the value below 0, the new value will be 0. Overflow in283 the "incr" command is not checked.282 to decrease the value below 0, the new value will be 0. Overflow in the 283 "incr" command will wrap around the 32 bit mark. 284 284 285 285 Note also that decrementing a number such that it loses length isn't trunk/server/memcached.c
r604 r608 89 89 static int add_iov(conn *c, const void *buf, int len); 90 90 static int add_msghdr(conn *c); 91 92 91 93 92 /* time handling */ … … 1258 1257 * returns a response string to send back to the client. 1259 1258 */ 1260 char *do_add_delta(item *it, const int incr, unsigned int delta, char *buf) {1259 char *do_add_delta(item *it, const int incr, const unsigned int delta, char *buf) { 1261 1260 char *ptr; 1262 u nsigned int value;1261 uint32_t value; 1263 1262 int res; 1264 1263 … … 1266 1265 while ((*ptr != '\0') && (*ptr < '0' && *ptr > '9')) ptr++; // BUG: can't be true 1267 1266 1268 value = strto l(ptr, NULL, 10);1267 value = strtoul(ptr, NULL, 10); 1269 1268 1270 1269 if(errno == ERANGE) { … … 2652 2651 } 2653 2652 2653 2654 2654 /* initialize main thread libevent instance */ 2655 2655 main_base = event_init(); trunk/server/t/incrdecr.t
r357 r608 2 2 3 3 use strict; 4 use Test::More tests => 1 3;4 use Test::More tests => 16; 5 5 use FindBin qw($Bin); 6 6 use lib "$Bin/lib"; … … 31 31 is(scalar <$sock>, "0\r\n", "- 5 = 0"); 32 32 33 print $sock "incr num ".(2**32-2)."\r\n"; 34 is(scalar <$sock>, (2**32-2)."\r\n", "+ ".(2**32-2)." = ".(2**32-2)); 35 36 print $sock "incr num 1\r\n"; 37 is(scalar <$sock>, (2**32-1)."\r\n", "+ 1 = ".(2**32-1)); 38 39 print $sock "incr num 1\r\n"; 40 is(scalar <$sock>, "0\r\n", "+ 1 = 0"); 41 33 42 print $sock "decr bogus 5\r\n"; 34 43 is(scalar <$sock>, "NOT_FOUND\r\n", "can't decr bogus key"); … … 41 50 print $sock "incr text 1\r\n"; 42 51 is(scalar <$sock>, "1\r\n", "hi - 1 = 0"); 43 44 trunk/server/thread.c
r595 r608 463 463 * Does arithmetic on a numeric item value. 464 464 */ 465 char *mt_add_delta(item *item, int incr, unsigned int delta, char *buf) {465 char *mt_add_delta(item *item, int incr, const unsigned int delta, char *buf) { 466 466 char *ret; 467 467
