Changeset 692
- Timestamp:
- 02/11/08 00:24:55 (10 months ago)
- Files:
-
- branches/binary/server/doc/binary-protocol-plan-v2.xml (modified) (1 diff)
- branches/binary/server/memcached.c (modified) (2 diffs)
- branches/binary/server/memcached.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/binary/server/doc/binary-protocol-plan-v2.xml
r687 r692 435 435 +---------------+---------------+---------------+---------------+ 436 436 Total 20 bytes 437 </artwork></figure> 438 </t> 439 440 <t> 441 <figure> 442 <preamble>incr/decr response body:</preamble> 443 <artwork> 444 Byte/ 0 | 1 | 2 | 3 | 445 / | | | | 446 |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7| 447 +---------------+---------------+---------------+---------------+ 448 0| 64-bit unsigned response. | 449 | | 450 +---------------+---------------+---------------+---------------+ 451 Total 8 bytes 437 452 </artwork></figure> 438 453 </t> branches/binary/server/memcached.c
r686 r692 942 942 char *key; 943 943 size_t nkey; 944 int i ,res;945 char *responseBuf =c->wbuf + BIN_INCR_HDR_LEN;944 int i; 945 uint64_t *responseBuf = (uint64_t*) c->wbuf + BIN_INCR_HDR_LEN; 946 946 947 947 assert(c != NULL); … … 981 981 if (it) { 982 982 /* Weird magic in add_delta forces me to pad here */ 983 memset(responseBuf, ' ', 32); 984 responseBuf[32]=0x00; 985 add_delta(it, c->cmd == CMD_INCR, delta, responseBuf); 986 res = strlen(responseBuf); 987 988 assert(res > 0); 989 write_bin_response(c, responseBuf, BIN_INCR_HDR_LEN, res); 983 char tmpbuf[INCR_MAX_STORAGE_LEN]; 984 uint64_t l=0; 985 memset(tmpbuf, ' ', INCR_MAX_STORAGE_LEN); 986 tmpbuf[INCR_MAX_STORAGE_LEN]=0x00; 987 add_delta(it, c->cmd == CMD_INCR, delta, tmpbuf); 988 *responseBuf=swap64(strtoull(tmpbuf, NULL, 10)); 989 990 write_bin_response(c, responseBuf, BIN_INCR_HDR_LEN, INCR_RES_LEN); 990 991 item_remove(it); /* release our reference */ 991 992 } else { 992 993 if(exptime >= 0) { 993 994 /* Save some room for the response */ 994 assert(c->wsize > BIN_INCR_HDR_LEN + 32); 995 snprintf(responseBuf, BIN_INCR_HDR_LEN + 32, "%llu", initial); 996 997 res = strlen(responseBuf); 998 it = item_alloc(key, nkey, 0, realtime(exptime), res + 2); 999 1000 memcpy(ITEM_data(it), responseBuf, res); 1001 995 assert(c->wsize > BIN_INCR_HDR_LEN + BIN_DEL_HDR_LEN); 996 *responseBuf=swap64(initial); 997 it = item_alloc(key, nkey, 0, realtime(exptime), 998 INCR_MAX_STORAGE_LEN); 999 snprintf(ITEM_data(it), INCR_MAX_STORAGE_LEN, "%llu", initial); 1000 1002 1001 if(store_item(it, NREAD_SET)) { 1003 write_bin_response(c, responseBuf, BIN_INCR_HDR_LEN, res); 1002 write_bin_response(c, responseBuf, BIN_INCR_HDR_LEN, 1003 INCR_RES_LEN); 1004 1004 } else { 1005 1005 write_bin_error(c, ERR_NOT_STORED, 0); branches/binary/server/memcached.h
r686 r692 50 50 #define BIN_DEL_HDR_LEN 4 51 51 #define BIN_PKT_HDR_WORDS (MIN_BIN_PKT_LENGTH/sizeof(uint32_t)) 52 53 /* Body is a single 64-bit int */ 54 #define INCR_RES_LEN 8 55 /* len(18446744073709551616) + 2 (or so) */ 56 #define INCR_MAX_STORAGE_LEN 24 52 57 53 58 #define BIN_REQ_MAGIC 0x80
