Changeset 760
- Timestamp:
- 03/19/08 05:18:15 (6 months ago)
- Files:
-
- branches/binary/server/doc/binary-protocol-plan-v2.txt (modified) (2 diffs)
- branches/binary/server/memcached.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/binary/server/doc/binary-protocol-plan-v2.txt
r705 r760 310 310 |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| 311 311 +---------------+---------------+---------------+---------------+ 312 0| Flags|313 +---------------+---------------+---------------+---------------+314 4| Data version check |315 ||312 0| Data version check | 313 | | 314 +---------------+---------------+---------------+---------------+ 315 8| Flags | 316 316 +---------------+---------------+---------------+---------------+ 317 317 Total 12 bytes … … 400 400 |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| 401 401 +---------------+---------------+---------------+---------------+ 402 0| Flags|403 +---------------+---------------+---------------+---------------+404 4| Expiration |405 +---------------+---------------+---------------+---------------+406 8| Data version check |407 ||402 0| Data version check | 403 | | 404 +---------------+---------------+---------------+---------------+ 405 8| Flags | 406 +---------------+---------------+---------------+---------------+ 407 12| Expiration | 408 408 +---------------+---------------+---------------+---------------+ 409 409 Total 16 bytes branches/binary/server/memcached.c
r759 r760 1085 1085 assert(c->rsize >= MIN_BIN_PKT_LENGTH + 4); 1086 1086 1087 /* This is a bit of magic. I'm using wbuf as the header, so I'll place1088 this is int in far enough to cover the header */1089 flags = (int*)(c->wbuf + MIN_BIN_PKT_LENGTH);1090 *flags = htonl(strtoul(ITEM_suffix(it), NULL, 10));1091 1092 1087 /* the length has two unnecessary bytes, and then we write four more */ 1093 1088 add_bin_header(c, 0, GET_RES_HDR_LEN, it->nbytes - 2 + GET_RES_HDR_LEN); 1094 /* Flags */ 1089 1090 /* Add the "extras" field: CAS-id followed by flags. The cas is a 64- 1091 bit datatype and require alignment to 8-byte boundaries on some 1092 architechtures. Verify that the size of the packet header is of 1093 the correct size (if not the following code generates SIGBUS on 1094 sparc hardware). 1095 */ 1096 assert(MIN_BIN_PKT_LENGTH % 8 == 0); 1097 identifier = (uint64_t*)(c->wbuf + MIN_BIN_PKT_LENGTH); 1098 *identifier = swap64(it->cas_id); 1099 add_iov(c, identifier, 8); 1100 1101 /* Add the flags */ 1102 flags = (int*)(c->wbuf + MIN_BIN_PKT_LENGTH + 8); 1103 *flags = htonl(strtoul(ITEM_suffix(it), NULL, 10)); 1095 1104 add_iov(c, flags, 4); 1096 identifier = (uint64_t*)(c->wbuf + MIN_BIN_PKT_LENGTH + 4); 1097 *identifier = swap64((uint32_t)it->cas_id); 1098 add_iov(c, identifier, 8); 1099 /* bytes minus the CRLF */ 1105 1106 /* Add the data minus the CRLF */ 1100 1107 add_iov(c, ITEM_data(it), it->nbytes - 2); 1101 1108 conn_set_state(c, conn_mwrite); … … 1173 1180 key[nkey] = 0x00; 1174 1181 1175 flags = ntohl(*((int*)(c->rbuf )));1176 exptime = ntohl(*((int*)(c->rbuf + 4)));1182 flags = ntohl(*((int*)(c->rbuf + 8))); 1183 exptime = ntohl(*((int*)(c->rbuf + 12))); 1177 1184 vlen = c->bin_header[2] - (nkey + hdrlen); 1178 1185 … … 1198 1205 } 1199 1206 1200 it->cas_id = (uint64_t)swap64(*((int64_t*)(c->rbuf + 8)));1207 it->cas_id = (uint64_t)swap64(*((int64_t*)(c->rbuf))); 1201 1208 1202 1209 switch(c->cmd) { … … 1289 1296 return; 1290 1297 } 1291 1298 1292 1299 c->msgcurr = 0; 1293 1300 c->msgused = 0; … … 1297 1304 return; 1298 1305 } 1299 1306 1300 1307 c->cmd = (c->bin_header[0] >> 16) & 0xff; 1301 1308 c->keylen = c->bin_header[0] & 0xffff;
