~brianaker/libmemcached/update-m4-sept

« back to all changes in this revision

Viewing changes to libmemcached/response.cc

  • Committer: Continuous Integration
  • Date: 2012-12-17 04:09:26 UTC
  • mfrom: (1088.1.3 libmemcached-1.2)
  • Revision ID: ci@tangent.org-20121217040926-h5fq4ad02z6l0a74
Merge lp:~tangent-org/libmemcached/1.2-build/ Build: jenkins-Libmemcached-169

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
 
61
61
  /* We load the key */
62
62
  {
63
 
    char *key= result->item_key;
64
 
    result->key_length= 0;
 
63
    char *key= result->impl()->item_key;
 
64
    result->impl()->key_length= 0;
65
65
 
66
66
    for (ptrdiff_t prefix_length= memcached_array_size(instance->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++)
67
67
    {
69
69
      {
70
70
        *key= *string_ptr;
71
71
        key++;
72
 
        result->key_length++;
 
72
        result->impl()->key_length++;
73
73
      }
74
74
      else
75
75
        prefix_length--;
76
76
    }
77
 
    result->item_key[result->key_length]= 0;
 
77
    result->impl()->item_key[result->impl()->key_length]= 0;
78
78
  }
79
79
 
80
80
  if (end_ptr == string_ptr)
90
90
  }
91
91
 
92
92
  for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {};
93
 
  result->item_flags= (uint32_t) strtoul(next_ptr, &string_ptr, 10);
 
93
  result->impl()->item_flags= (uint32_t) strtoul(next_ptr, &string_ptr, 10);
94
94
 
95
95
  if (end_ptr == string_ptr)
96
96
  {
122
122
  {
123
123
    string_ptr++;
124
124
    for (next_ptr= string_ptr; isdigit(*string_ptr); string_ptr++) {};
125
 
    result->item_cas= strtoull(next_ptr, &string_ptr, 10);
 
125
    result->impl()->item_cas= strtoull(next_ptr, &string_ptr, 10);
126
126
  }
127
127
 
128
128
  if (end_ptr < string_ptr)
131
131
  }
132
132
 
133
133
  /* We add two bytes so that we can walk the \r\n */
134
 
  if (memcached_failed(memcached_string_check(&result->value, value_length +2)))
 
134
  if (memcached_failed(memcached_string_check(&result->impl()->value, value_length +2)))
135
135
  {
136
136
    return memcached_set_error(*instance, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT);
137
137
  }
138
138
 
139
139
  {
140
 
    char *value_ptr= memcached_string_value_mutable(&result->value);
 
140
    char *value_ptr= memcached_string_value_mutable(&result->impl()->value);
141
141
    /*
142
142
      We read the \r\n into the string since not doing so is more
143
143
      cycles then the waster of memory to do so.
166
166
  /* This next bit blows the API, but this is internal....*/
167
167
  {
168
168
    char *char_ptr;
169
 
    char_ptr= memcached_string_value_mutable(&result->value);;
 
169
    char_ptr= memcached_string_value_mutable(&result->impl()->value);
170
170
    char_ptr[value_length]= 0;
171
171
    char_ptr[value_length +1]= 0;
172
 
    memcached_string_set_length(&result->value, value_length);
 
172
    memcached_string_set_length(&result->impl()->value, value_length);
173
173
  }
174
174
 
175
175
  if (memcached_is_encrypted(instance->root) and memcached_result_length(result))
446
446
 
447
447
      if (auto_return_value == ULLONG_MAX and errno == ERANGE)
448
448
      {
449
 
        result->numeric_value= UINT64_MAX;
 
449
        result->impl()->numeric_value= UINT64_MAX;
450
450
        return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
451
451
                                   memcached_literal_param("Numeric response was out of range"));
452
452
      }
453
453
      else if (errno == EINVAL)
454
454
      {
455
 
        result->numeric_value= UINT64_MAX;
 
455
        result->impl()->numeric_value= UINT64_MAX;
456
456
        return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT,
457
457
                                   memcached_literal_param("Numeric response was out of range"));
458
458
      }
459
459
 
460
 
      result->numeric_value= uint64_t(auto_return_value);
 
460
      result->impl()->numeric_value= uint64_t(auto_return_value);
461
461
 
462
462
      WATCHPOINT_STRING(buffer);
463
463
      return MEMCACHED_SUCCESS;
523
523
      {
524
524
        uint16_t keylen= header.response.keylen;
525
525
        memcached_result_reset(result);
526
 
        result->item_cas= header.response.cas;
 
526
        result->impl()->item_cas= header.response.cas;
527
527
 
528
 
        if ((rc= memcached_safe_read(instance, &result->item_flags, sizeof (result->item_flags))) != MEMCACHED_SUCCESS)
 
528
        if ((rc= memcached_safe_read(instance, &result->impl()->item_flags, sizeof (result->impl()->item_flags))) != MEMCACHED_SUCCESS)
529
529
        {
530
530
          WATCHPOINT_ERROR(rc);
531
531
          return MEMCACHED_UNKNOWN_READ_FAILURE;
532
532
        }
533
533
 
534
 
        result->item_flags= ntohl(result->item_flags);
 
534
        result->impl()->item_flags= ntohl(result->impl()->item_flags);
535
535
        bodylen -= header.response.extlen;
536
536
 
537
 
        result->key_length= keylen;
538
 
        if (memcached_failed(rc= memcached_safe_read(instance, result->item_key, keylen)))
 
537
        result->impl()->key_length= keylen;
 
538
        if (memcached_failed(rc= memcached_safe_read(instance, result->impl()->item_key, keylen)))
539
539
        {
540
540
          WATCHPOINT_ERROR(rc);
541
541
          return MEMCACHED_UNKNOWN_READ_FAILURE;
542
542
        }
543
543
 
544
544
        // Only bother with doing this if key_length > 0
545
 
        if (result->key_length)
 
545
        if (result->impl()->key_length)
546
546
        {
547
 
          if (memcached_array_size(instance->root->_namespace) and memcached_array_size(instance->root->_namespace) >= result->key_length)
 
547
          if (memcached_array_size(instance->root->_namespace) and memcached_array_size(instance->root->_namespace) >= result->impl()->key_length)
548
548
          {
549
549
            return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT);
550
550
          }
551
551
 
552
552
          if (memcached_array_size(instance->root->_namespace))
553
553
          {
554
 
            result->key_length-= memcached_array_size(instance->root->_namespace);
555
 
            memmove(result->item_key, result->item_key +memcached_array_size(instance->root->_namespace), result->key_length);
 
554
            result->impl()->key_length-= memcached_array_size(instance->root->_namespace);
 
555
            memmove(result->impl()->item_key, result->impl()->item_key +memcached_array_size(instance->root->_namespace), result->impl()->key_length);
556
556
          }
557
557
        }
558
558
 
559
559
        bodylen -= keylen;
560
 
        if (memcached_failed(memcached_string_check(&result->value, bodylen)))
 
560
        if (memcached_failed(memcached_string_check(&result->impl()->value, bodylen)))
561
561
        {
562
562
          return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
563
563
        }
564
564
 
565
 
        char *vptr= memcached_string_value_mutable(&result->value);
 
565
        char *vptr= memcached_string_value_mutable(&result->impl()->value);
566
566
        if (memcached_failed(rc= memcached_safe_read(instance, vptr, bodylen)))
567
567
        {
568
568
          WATCHPOINT_ERROR(rc);
569
569
          return MEMCACHED_UNKNOWN_READ_FAILURE;
570
570
        }
571
571
 
572
 
        memcached_string_set_length(&result->value, bodylen);
 
572
        memcached_string_set_length(&result->impl()->value, bodylen);
573
573
      }
574
574
      break;
575
575
 
578
578
      {
579
579
        if (bodylen != sizeof(uint64_t))
580
580
        {
581
 
          result->numeric_value= UINT64_MAX;
 
581
          result->impl()->numeric_value= UINT64_MAX;
582
582
          return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT);
583
583
        }
584
584
 
585
585
        uint64_t val;
586
586
        if ((rc= memcached_safe_read(instance, &val, sizeof(val))) != MEMCACHED_SUCCESS)
587
587
        {
588
 
          result->numeric_value= UINT64_MAX;
 
588
          result->impl()->numeric_value= UINT64_MAX;
589
589
          return MEMCACHED_UNKNOWN_READ_FAILURE;
590
590
        }
591
591
 
592
 
        result->numeric_value= memcached_ntohll(val);
 
592
        result->impl()->numeric_value= memcached_ntohll(val);
593
593
      }
594
594
      break;
595
595
 
697
697
    case PROTOCOL_BINARY_CMD_SASL_STEP:
698
698
      {
699
699
        memcached_result_reset(result);
700
 
        result->item_cas= header.response.cas;
 
700
        result->impl()->item_cas= header.response.cas;
701
701
 
702
 
        if (memcached_string_check(&result->value,
 
702
        if (memcached_string_check(&result->impl()->value,
703
703
                                   bodylen) != MEMCACHED_SUCCESS)
704
704
          return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
705
705
 
706
 
        char *vptr= memcached_string_value_mutable(&result->value);
 
706
        char *vptr= memcached_string_value_mutable(&result->impl()->value);
707
707
        if ((rc= memcached_safe_read(instance, vptr, bodylen)) != MEMCACHED_SUCCESS)
708
708
        {
709
709
          WATCHPOINT_ERROR(rc);
710
710
          return MEMCACHED_UNKNOWN_READ_FAILURE;
711
711
        }
712
712
 
713
 
        memcached_string_set_length(&result->value, bodylen);
 
713
        memcached_string_set_length(&result->impl()->value, bodylen);
714
714
      }
715
715
      break;
716
716
    default: