@@ -1191,7 +1191,6 @@ static hash_item *do_item_get(struct default_engine *engine,
11911191 *
11921192 * Returns the state of storage.
11931193 */
1194- #ifdef REFACTOR_STORE
11951194static ENGINE_ERROR_CODE do_item_store_set (struct default_engine * engine , hash_item * it ,
11961195 uint64_t * cas , const void * cookie )
11971196{
@@ -1341,119 +1340,6 @@ static ENGINE_ERROR_CODE do_item_store_attach(struct default_engine *engine, has
13411340 }
13421341 return stored ;
13431342}
1344- #else
1345- static ENGINE_ERROR_CODE do_store_item (struct default_engine * engine , hash_item * it , uint64_t * cas ,
1346- ENGINE_STORE_OPERATION operation , const void * cookie )
1347- {
1348- const char * key = item_get_key (it );
1349- hash_item * old_it = do_item_get (engine , key , it -> nkey , DONT_UPDATE );
1350- ENGINE_ERROR_CODE stored = ENGINE_NOT_STORED ;
1351- if (old_it != NULL && IS_COLL_ITEM (old_it )) {
1352- do_item_release (engine , old_it );
1353- return ENGINE_EBADTYPE ;
1354- }
1355-
1356- hash_item * new_it = NULL ;
1357-
1358- if (old_it != NULL && operation == OPERATION_ADD ) {
1359- /* add only adds a nonexistent item, but promote to head of LRU */
1360- do_item_update (engine , old_it );
1361- } else if (!old_it && (operation == OPERATION_REPLACE
1362- || operation == OPERATION_APPEND || operation == OPERATION_PREPEND ))
1363- {
1364- /* replace only replaces an existing value; don't store */
1365- } else if (operation == OPERATION_CAS ) {
1366- /* validate cas operation */
1367- if (old_it == NULL ) {
1368- // LRU expired
1369- stored = ENGINE_KEY_ENOENT ;
1370- }
1371- else if (item_get_cas (it ) == item_get_cas (old_it )) {
1372- // cas validates
1373- // it and old_it may belong to different classes.
1374- // I'm updating the stats for the one that's getting pushed out
1375- do_item_replace (engine , old_it , it );
1376- stored = ENGINE_SUCCESS ;
1377- } else {
1378- if (engine -> config .verbose > 1 ) {
1379- logger -> log (EXTENSION_LOG_WARNING , NULL ,
1380- "CAS: failure: expected %" PRIu64 ", got %" PRIu64 "\n" ,
1381- item_get_cas (old_it ), item_get_cas (it ));
1382- }
1383- stored = ENGINE_KEY_EEXISTS ;
1384- }
1385- } else {
1386- /*
1387- * Append - combine new and old record into single one. Here it's
1388- * atomic and thread-safe.
1389- */
1390- if (operation == OPERATION_APPEND || operation == OPERATION_PREPEND ) {
1391- /*
1392- * Validate CAS
1393- */
1394- if (item_get_cas (it ) != 0 ) {
1395- // CAS much be equal
1396- if (item_get_cas (it ) != item_get_cas (old_it )) {
1397- stored = ENGINE_KEY_EEXISTS ;
1398- }
1399- }
1400-
1401- if (stored == ENGINE_NOT_STORED ) {
1402- /* we have it and old_it here - alloc memory to hold both */
1403- new_it = do_item_alloc (engine , key , it -> nkey ,
1404- old_it -> flags , old_it -> exptime ,
1405- it -> nbytes + old_it -> nbytes - 2 /* CRLF */ ,
1406- cookie );
1407-
1408- if (new_it == NULL ) {
1409- /* SERVER_ERROR out of memory */
1410- if (old_it != NULL ) {
1411- do_item_release (engine , old_it );
1412- }
1413-
1414- return ENGINE_NOT_STORED ;
1415- }
1416-
1417- /* copy data from it and old_it to new_it */
1418-
1419- if (operation == OPERATION_APPEND ) {
1420- memcpy (item_get_data (new_it ), item_get_data (old_it ), old_it -> nbytes );
1421- memcpy (item_get_data (new_it ) + old_it -> nbytes - 2 /* CRLF */ , item_get_data (it ), it -> nbytes );
1422- } else {
1423- /* OPERATION_PREPEND */
1424- memcpy (item_get_data (new_it ), item_get_data (it ), it -> nbytes );
1425- memcpy (item_get_data (new_it ) + it -> nbytes - 2 /* CRLF */ , item_get_data (old_it ), old_it -> nbytes );
1426- }
1427-
1428- it = new_it ;
1429- }
1430- }
1431- if (stored == ENGINE_NOT_STORED ) {
1432- if (old_it != NULL ) {
1433- do_item_replace (engine , old_it , it );
1434- stored = ENGINE_SUCCESS ;
1435- } else {
1436- stored = do_item_link (engine , it );
1437- }
1438- if (stored == ENGINE_SUCCESS ) {
1439- * cas = item_get_cas (it );
1440- }
1441- }
1442- }
1443-
1444- if (old_it != NULL ) {
1445- do_item_release (engine , old_it ); /* release our reference */
1446- }
1447- if (new_it != NULL ) {
1448- do_item_release (engine , new_it );
1449- }
1450- if (stored == ENGINE_SUCCESS ) {
1451- * cas = item_get_cas (it );
1452- }
1453- return stored ;
1454- }
1455- #endif
1456-
14571343
14581344/*
14591345 * adds a delta value to a numeric item.
@@ -6157,7 +6043,6 @@ ENGINE_ERROR_CODE store_item(struct default_engine *engine,
61576043 ENGINE_ERROR_CODE ret ;
61586044
61596045 pthread_mutex_lock (& engine -> cache_lock );
6160- #ifdef REFACTOR_STORE
61616046 switch (operation ) {
61626047 case OPERATION_SET :
61636048 ret = do_item_store_set (engine , item , cas , cookie );
@@ -6178,9 +6063,6 @@ ENGINE_ERROR_CODE store_item(struct default_engine *engine,
61786063 default :
61796064 ret = ENGINE_NOT_STORED ;
61806065 }
6181- #else
6182- ret = do_store_item (engine , item , cas , operation , cookie );
6183- #endif
61846066 pthread_mutex_unlock (& engine -> cache_lock );
61856067 return ret ;
61866068}
@@ -6215,11 +6097,7 @@ static ENGINE_ERROR_CODE do_arithmetic(struct default_engine *engine,
62156097 }
62166098 memcpy ((void * )item_get_data (it ), buffer , len );
62176099
6218- #ifdef REFACTOR_STORE
62196100 ret = do_item_store_add (engine , it , cas , cookie );
6220- #else
6221- ret = do_store_item (engine , it , cas , OPERATION_ADD , cookie );
6222- #endif
62236101 if (ret == ENGINE_SUCCESS ) {
62246102 * result = initial ;
62256103 }
0 commit comments