Changeset 620 for trunk/server/memcached.c
- Timestamp:
- 10/03/07 22:27:28 (2 years ago)
- Files:
-
- 1 modified
-
trunk/server/memcached.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/memcached.c
r619 r620 1160 1160 int flags; 1161 1161 time_t exptime; 1162 int vlen ;1162 int vlen, old_vlen; 1163 1163 uint32_t req_memory_ptr, in_memory_ptr; 1164 1165 item *it; 1164 item *it, *old_it; 1166 1165 1167 1166 assert(c != NULL); … … 1207 1206 } 1208 1207 1208 /* Check if append -- if yes, search for previous entry, and allocate memory for both */ 1209 if( comm == NREAD_APPEND ){ 1210 old_it = assoc_find(key,nkey); 1211 1212 if( old_it && (old_it->nbytes)>2 ){ // previous must be more than \r\n 1213 old_vlen = old_it->nbytes - 2; 1214 vlen += old_vlen; // append the length of old data 1215 } else { 1216 comm = NREAD_REPLACE; // no old entry: treat as replace 1217 } 1218 } 1219 1209 1220 it = item_alloc(key, nkey, flags, realtime(exptime), vlen+2); 1210 1221 1211 1222 /* HANDLE_CAS VALIDATION */ 1212 if (handle_cas == true)1223 if (handle_cas == true) 1213 1224 { 1214 1225 item *itmp=item_get(key, it->nkey); … … 1252 1263 } 1253 1264 1254 c->item_comm = comm;1255 1265 c->item = it; 1256 1266 c->ritem = ITEM_data(it); 1257 1267 c->rlbytes = it->nbytes; 1268 1269 1270 /* If append, prepend old data before new - adjust item, rlbytes variables too 1271 * Now that data has been merged, treat simply as a replace command 1272 */ 1273 if (comm == NREAD_APPEND ){ 1274 memcpy( c->ritem, ITEM_data(old_it), old_vlen ); 1275 c->ritem += old_vlen; 1276 c->rlbytes -= old_vlen; 1277 comm = NREAD_REPLACE; 1278 } 1279 1280 c->item_comm = comm; 1258 1281 conn_set_state(c, conn_nread); 1259 1282 } … … 1488 1511 ((strcmp(tokens[COMMAND_TOKEN].value, "add") == 0 && (comm = NREAD_ADD)) || 1489 1512 (strcmp(tokens[COMMAND_TOKEN].value, "set") == 0 && (comm = NREAD_SET)) || 1490 (strcmp(tokens[COMMAND_TOKEN].value, "replace") == 0 && (comm = NREAD_REPLACE)))) { 1513 (strcmp(tokens[COMMAND_TOKEN].value, "replace") == 0 && (comm = NREAD_REPLACE)) || 1514 (strcmp(tokens[COMMAND_TOKEN].value, "append") == 0 && (comm = NREAD_APPEND)) )) { 1491 1515 1492 1516 process_update_command(c, tokens, ntokens, comm, false);
