| 60 | } |
| 61 | |
| 62 | bool MemcacheRequest::MergePartialFromCodedStream( |
| 63 | ::google::protobuf::io::CodedInputStream* input) { |
| 64 | LOG(WARNING) << "You're not supposed to parse a MemcacheRequest"; |
| 65 | |
| 66 | // simple approach just making it work. |
| 67 | butil::IOBuf tmp; |
| 68 | const void* data = NULL; |
| 69 | int size = 0; |
| 70 | while (input->GetDirectBufferPointer(&data, &size)) { |
| 71 | tmp.append(data, size); |
| 72 | input->Skip(size); |
| 73 | } |
| 74 | const butil::IOBuf saved = tmp; |
| 75 | int count = 0; |
| 76 | for (; !tmp.empty(); ++count) { |
| 77 | char aux_buf[sizeof(policy::MemcacheRequestHeader)]; |
| 78 | const policy::MemcacheRequestHeader* header = |
| 79 | (const policy::MemcacheRequestHeader*)tmp.fetch(aux_buf, sizeof(aux_buf)); |
| 80 | if (header == NULL) { |
| 81 | return false; |
| 82 | } |
| 83 | if (header->magic != (uint8_t)policy::MC_MAGIC_REQUEST) { |
| 84 | return false; |
| 85 | } |
| 86 | uint32_t total_body_length = butil::NetToHost32(header->total_body_length); |
| 87 | if (tmp.size() < sizeof(*header) + total_body_length) { |
| 88 | return false; |
| 89 | } |
| 90 | tmp.pop_front(sizeof(*header) + total_body_length); |
| 91 | } |
| 92 | _buf.append(saved); |
| 93 | _pipelined_count += count; |
| 94 | return true; |
| 95 | } |
| 96 | |
| 97 | void MemcacheRequest::SerializeWithCachedSizes( |
| 98 | ::google::protobuf::io::CodedOutputStream* output) const { |