@@ -236,6 +236,7 @@ static void settings_init(void) {
236
236
settings .hot_lru_pct = 32 ;
237
237
settings .warm_lru_pct = 32 ;
238
238
settings .expirezero_does_not_evict = false;
239
+ settings .inline_ascii_response = false;
239
240
settings .idle_timeout = 0 ; /* disabled */
240
241
settings .hashpower_init = 0 ;
241
242
settings .slab_reassign = false;
@@ -1507,7 +1508,11 @@ static void process_bin_get_or_touch(conn *c) {
1507
1508
rsp -> message .header .response .cas = htonll (ITEM_get_cas (it ));
1508
1509
1509
1510
// add the flags
1510
- rsp -> message .body .flags = htonl (strtoul (ITEM_suffix (it ), NULL , 10 ));
1511
+ if (settings .inline_ascii_response ) {
1512
+ rsp -> message .body .flags = htonl (strtoul (ITEM_suffix (it ), NULL , 10 ));
1513
+ } else {
1514
+ rsp -> message .body .flags = htonl (* ((uint32_t * )ITEM_suffix (it )));
1515
+ }
1511
1516
add_iov (c , & rsp -> message .body , sizeof (rsp -> message .body ));
1512
1517
1513
1518
if (should_return_key ) {
@@ -2656,7 +2661,11 @@ enum store_item_type do_store_item(item *it, int comm, conn *c, const uint32_t h
2656
2661
/* we have it and old_it here - alloc memory to hold both */
2657
2662
/* flags was already lost - so recover them from ITEM_suffix(it) */
2658
2663
2659
- flags = (uint32_t ) strtoul (ITEM_suffix (old_it ), (char * * ) NULL , 10 );
2664
+ if (settings .inline_ascii_response ) {
2665
+ flags = (uint32_t ) strtoul (ITEM_suffix (old_it ), (char * * ) NULL , 10 );
2666
+ } else {
2667
+ flags = * ((uint32_t * )ITEM_suffix (old_it ));
2668
+ }
2660
2669
2661
2670
new_it = do_item_alloc (key , it -> nkey , flags , old_it -> exptime , it -> nbytes + old_it -> nbytes - 2 /* CRLF */ );
2662
2671
@@ -3179,6 +3188,22 @@ static void process_stat(conn *c, token_t *tokens, const size_t ntokens) {
3179
3188
}
3180
3189
}
3181
3190
3191
+ static inline int make_ascii_get_suffix (char * suffix , item * it , bool return_cas ) {
3192
+ char * p ;
3193
+ * suffix = ' ' ;
3194
+ p = itoa_u32 (* ((uint32_t * ) ITEM_suffix (it )), suffix + 1 );
3195
+ * p = ' ' ;
3196
+ p = itoa_u32 (it -> nbytes - 2 , p + 1 );
3197
+ if (return_cas ) {
3198
+ * p = ' ' ;
3199
+ p = itoa_u64 (ITEM_get_cas (it ), p + 1 );
3200
+ }
3201
+ * p = '\r' ;
3202
+ * (p + 1 ) = '\n' ;
3203
+ * (p + 2 ) = '\0' ;
3204
+ return (p - suffix ) + 2 ;
3205
+ }
3206
+
3182
3207
/* ntokens is overwritten here... shrug.. */
3183
3208
static inline void process_get_command (conn * c , token_t * tokens , size_t ntokens , bool return_cas ) {
3184
3209
char * key ;
@@ -3230,7 +3255,7 @@ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens,
3230
3255
* " " + flags + " " + data length + "\r\n" + data (with \r\n)
3231
3256
*/
3232
3257
3233
- if (return_cas )
3258
+ if (return_cas || ! settings . inline_ascii_response )
3234
3259
{
3235
3260
MEMCACHED_COMMAND_GET (c -> sfd , ITEM_key (it ), it -> nkey ,
3236
3261
it -> nbytes , ITEM_get_cas (it ));
@@ -3263,12 +3288,13 @@ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens,
3263
3288
return ;
3264
3289
}
3265
3290
* (c -> suffixlist + i ) = suffix ;
3266
- int suffix_len = snprintf (suffix , SUFFIX_SIZE ,
3291
+ /* int suffix_len = snprintf(suffix, SUFFIX_SIZE,
3267
3292
" %llu\r\n",
3268
- (unsigned long long )ITEM_get_cas (it ));
3293
+ (unsigned long long)ITEM_get_cas(it));*/
3294
+ int suffix_len = make_ascii_get_suffix (suffix , it , return_cas );
3295
+ //add_iov(c, ITEM_suffix(it), it->nsuffix - 2) != 0 ||
3269
3296
if (add_iov (c , "VALUE " , 6 ) != 0 ||
3270
3297
add_iov (c , ITEM_key (it ), it -> nkey ) != 0 ||
3271
- add_iov (c , ITEM_suffix (it ), it -> nsuffix - 2 ) != 0 ||
3272
3298
add_iov (c , suffix , suffix_len ) != 0 )
3273
3299
{
3274
3300
item_remove (it );
@@ -3348,7 +3374,7 @@ static inline void process_get_command(conn *c, token_t *tokens, size_t ntokens,
3348
3374
3349
3375
c -> icurr = c -> ilist ;
3350
3376
c -> ileft = i ;
3351
- if (return_cas ) {
3377
+ if (return_cas || ! settings . inline_ascii_response ) {
3352
3378
c -> suffixcurr = c -> suffixlist ;
3353
3379
c -> suffixleft = i ;
3354
3380
}
@@ -3639,7 +3665,12 @@ enum delta_result_type do_add_delta(conn *c, const char *key, const size_t nkey,
3639
3665
do_item_update (it );
3640
3666
} else if (it -> refcount > 1 ) {
3641
3667
item * new_it ;
3642
- uint32_t flags = (uint32_t ) strtoul (ITEM_suffix (it )+ 1 , (char * * ) NULL , 10 );
3668
+ uint32_t flags ;
3669
+ if (settings .inline_ascii_response ) {
3670
+ flags = (uint32_t ) strtoul (ITEM_suffix (it )+ 1 , (char * * ) NULL , 10 );
3671
+ } else {
3672
+ flags = * ((uint32_t * )ITEM_suffix (it ));
3673
+ }
3643
3674
new_it = do_item_alloc (ITEM_key (it ), it -> nkey , flags , it -> exptime , res + 2 );
3644
3675
if (new_it == 0 ) {
3645
3676
do_item_remove (it );
0 commit comments