libcouchbase 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libcouchbase/.gitignore +2 -0
  3. data/ext/libcouchbase/CMakeLists.txt +5 -7
  4. data/ext/libcouchbase/README.markdown +2 -2
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +49 -0
  6. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
  7. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
  8. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +2 -1
  9. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  10. data/ext/libcouchbase/cmake/config-cmake.h.in +2 -0
  11. data/ext/libcouchbase/cmake/defs.mk.in +0 -2
  12. data/ext/libcouchbase/cmake/source_files.cmake +34 -14
  13. data/ext/libcouchbase/configure.pl +1 -1
  14. data/ext/libcouchbase/contrib/genhash/genhash.h +6 -0
  15. data/ext/libcouchbase/include/libcouchbase/auth.h +10 -0
  16. data/ext/libcouchbase/include/libcouchbase/couchbase.h +10 -0
  17. data/ext/libcouchbase/include/libcouchbase/error.h +7 -0
  18. data/ext/libcouchbase/include/libcouchbase/n1ql.h +13 -1
  19. data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +1 -1
  20. data/ext/libcouchbase/include/libcouchbase/subdoc.h +9 -0
  21. data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
  22. data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
  23. data/ext/libcouchbase/include/memcached/protocol_binary.h +21 -1132
  24. data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
  25. data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
  26. data/ext/libcouchbase/src/README.md +0 -2
  27. data/ext/libcouchbase/src/auth-priv.h +1 -0
  28. data/ext/libcouchbase/src/auth.cc +10 -0
  29. data/ext/libcouchbase/src/bootstrap.cc +216 -0
  30. data/ext/libcouchbase/src/bootstrap.h +50 -39
  31. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +455 -0
  32. data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
  33. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +528 -0
  34. data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
  35. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.cc +115 -0
  36. data/ext/libcouchbase/src/bucketconfig/clconfig.h +407 -386
  37. data/ext/libcouchbase/src/bucketconfig/confmon.cc +378 -0
  38. data/ext/libcouchbase/src/cbft.cc +22 -27
  39. data/ext/libcouchbase/src/cntl.cc +24 -24
  40. data/ext/libcouchbase/src/connspec.cc +30 -1
  41. data/ext/libcouchbase/src/connspec.h +17 -0
  42. data/ext/libcouchbase/src/dns-srv.cc +143 -0
  43. data/ext/libcouchbase/src/{dump.c → dump.cc} +8 -11
  44. data/ext/libcouchbase/src/getconfig.cc +73 -0
  45. data/ext/libcouchbase/src/handler.cc +84 -85
  46. data/ext/libcouchbase/src/hostlist.cc +0 -1
  47. data/ext/libcouchbase/src/hostlist.h +6 -1
  48. data/ext/libcouchbase/src/http/http-priv.h +125 -112
  49. data/ext/libcouchbase/src/http/http.cc +9 -29
  50. data/ext/libcouchbase/src/http/http.h +1 -34
  51. data/ext/libcouchbase/src/http/http_io.cc +22 -26
  52. data/ext/libcouchbase/src/instance.cc +102 -28
  53. data/ext/libcouchbase/src/internal.h +47 -29
  54. data/ext/libcouchbase/src/jsparse/parser.cc +146 -202
  55. data/ext/libcouchbase/src/jsparse/parser.h +91 -98
  56. data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
  57. data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
  58. data/ext/libcouchbase/src/lcbio/connect.cc +562 -0
  59. data/ext/libcouchbase/src/lcbio/connect.h +9 -2
  60. data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
  61. data/ext/libcouchbase/src/lcbio/iotable.h +61 -16
  62. data/ext/libcouchbase/src/lcbio/ioutils.h +1 -1
  63. data/ext/libcouchbase/src/lcbio/manager.c +2 -2
  64. data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
  65. data/ext/libcouchbase/src/mc/mcreq.h +9 -2
  66. data/ext/libcouchbase/src/mcserver/mcserver.cc +723 -0
  67. data/ext/libcouchbase/src/mcserver/mcserver.h +160 -70
  68. data/ext/libcouchbase/src/mcserver/negotiate.cc +118 -152
  69. data/ext/libcouchbase/src/mcserver/negotiate.h +85 -74
  70. data/ext/libcouchbase/src/mctx-helper.h +51 -0
  71. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
  72. data/ext/libcouchbase/src/n1ql/n1ql.cc +56 -32
  73. data/ext/libcouchbase/src/{newconfig.c → newconfig.cc} +42 -70
  74. data/ext/libcouchbase/src/nodeinfo.cc +4 -8
  75. data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
  76. data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
  77. data/ext/libcouchbase/src/operations/{durability-cas.c → durability-cas.cc} +92 -76
  78. data/ext/libcouchbase/src/operations/{durability-seqno.c → durability-seqno.cc} +55 -49
  79. data/ext/libcouchbase/src/operations/durability.cc +643 -0
  80. data/ext/libcouchbase/src/operations/durability_internal.h +212 -124
  81. data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
  82. data/ext/libcouchbase/src/operations/{observe-seqno.c → observe-seqno.cc} +5 -8
  83. data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +69 -94
  84. data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
  85. data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
  86. data/ext/libcouchbase/src/operations/{stats.c → stats.cc} +66 -78
  87. data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
  88. data/ext/libcouchbase/src/operations/subdoc.cc +38 -18
  89. data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
  90. data/ext/libcouchbase/src/packetutils.h +200 -137
  91. data/ext/libcouchbase/src/probes.d +1 -1
  92. data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +3 -4
  93. data/ext/libcouchbase/src/retryq.cc +394 -0
  94. data/ext/libcouchbase/src/retryq.h +116 -104
  95. data/ext/libcouchbase/src/settings.h +2 -1
  96. data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
  97. data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
  98. data/ext/libcouchbase/src/trace.h +8 -8
  99. data/ext/libcouchbase/src/vbucket/vbucket.c +0 -1
  100. data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
  101. data/ext/libcouchbase/src/views/docreq.h +24 -30
  102. data/ext/libcouchbase/src/views/viewreq.cc +318 -0
  103. data/ext/libcouchbase/src/views/viewreq.h +43 -13
  104. data/ext/libcouchbase/src/{wait.c → wait.cc} +12 -17
  105. data/ext/libcouchbase/tests/basic/t_connstr.cc +89 -50
  106. data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -78
  107. data/ext/libcouchbase/tests/basic/t_packet.cc +35 -42
  108. data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
  109. data/ext/libcouchbase/tests/iotests/t_confmon.cc +94 -111
  110. data/ext/libcouchbase/tests/iotests/t_sched.cc +1 -2
  111. data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
  112. data/ext/libcouchbase/tools/cbc-pillowfight.cc +1 -1
  113. data/lib/libcouchbase/version.rb +1 -1
  114. metadata +36 -39
  115. data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
  116. data/ext/libcouchbase/src/bootstrap.c +0 -269
  117. data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +0 -495
  118. data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
  119. data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
  120. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
  121. data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
  122. data/ext/libcouchbase/src/getconfig.c +0 -100
  123. data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
  124. data/ext/libcouchbase/src/lcbio/connect.c +0 -557
  125. data/ext/libcouchbase/src/mcserver/mcserver.c +0 -784
  126. data/ext/libcouchbase/src/operations/durability.c +0 -668
  127. data/ext/libcouchbase/src/packetutils.c +0 -60
  128. data/ext/libcouchbase/src/retryq.c +0 -424
  129. data/ext/libcouchbase/src/simplestring.c +0 -211
  130. data/ext/libcouchbase/src/simplestring.h +0 -228
  131. data/ext/libcouchbase/src/ssobuf.h +0 -82
  132. data/ext/libcouchbase/src/views/viewreq.c +0 -358
  133. data/ext/libcouchbase/tests/basic/t_string.cc +0 -112
@@ -21,6 +21,8 @@
21
21
  #include "mc/compress.h"
22
22
  #include "trace.h"
23
23
 
24
+ using lcb::MemcachedResponse;
25
+
24
26
  template <typename T>
25
27
  class ResponsePack {
26
28
  public:
@@ -161,23 +163,22 @@ find_callback(lcb_t instance, lcb_CALLBACKTYPE type)
161
163
 
162
164
  template <typename T>
163
165
  void make_error(lcb_t instance, T* resp,
164
- const packet_info *response, lcb_error_t imm) {
166
+ const MemcachedResponse *response, lcb_error_t imm) {
165
167
  if (imm) {
166
168
  resp->rc = imm;
167
169
  resp->rflags |= LCB_RESP_F_CLIENTGEN;
168
- } else if (PACKET_STATUS(response) == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
170
+ } else if (response->status() == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
169
171
  resp->rc = LCB_SUCCESS;
170
172
  } else {
171
- resp->rc = map_error(instance, PACKET_STATUS(response));
173
+ resp->rc = map_error(instance, response->status());
172
174
  }
173
175
  }
174
176
 
175
177
  template <typename T>
176
- void init_resp(lcb_t instance, const packet_info *mc_resp, const mc_PACKET *req,
177
- lcb_error_t immerr, T *resp)
178
- {
178
+ void init_resp(lcb_t instance, const MemcachedResponse* mc_resp,
179
+ const mc_PACKET *req, lcb_error_t immerr, T *resp) {
179
180
  make_error(instance, resp, mc_resp, immerr);
180
- resp->cas = PACKET_CAS(mc_resp);
181
+ resp->cas = mc_resp->cas();
181
182
  resp->cookie = const_cast<void*>(MCREQ_PKT_COOKIE(req));
182
183
  mcreq_get_key(req, &resp->key, &resp->nkey);
183
184
  }
@@ -189,13 +190,12 @@ void init_resp(lcb_t instance, const packet_info *mc_resp, const mc_PACKET *req,
189
190
  * @param tgt Pointer to mutation token which should be populated.
190
191
  */
191
192
  static void
192
- handle_mutation_token(lcb_t instance, const packet_info *mc_resp,
193
+ handle_mutation_token(lcb_t instance, const MemcachedResponse *mc_resp,
193
194
  const mc_PACKET *req, lcb_MUTATION_TOKEN *stok)
194
195
  {
195
196
  const char *sbuf;
196
197
  uint16_t vbid;
197
-
198
- if (PACKET_EXTLEN(mc_resp) == 0) {
198
+ if (mc_resp->extlen() == 0) {
199
199
  return; /* No extras */
200
200
  }
201
201
 
@@ -207,7 +207,7 @@ handle_mutation_token(lcb_t instance, const packet_info *mc_resp,
207
207
  }
208
208
  }
209
209
 
210
- sbuf = reinterpret_cast<const char *>(PACKET_BODY(mc_resp));
210
+ sbuf = mc_resp->body<const char*>();
211
211
  vbid = mcreq_get_vbucket(req);
212
212
  stok->vbid_ = vbid;
213
213
  memcpy(&stok->uuid_, sbuf, 8);
@@ -259,22 +259,22 @@ void invoke_callback(const mc_PACKET *pkt, mc_PIPELINE *pipeline, T *resp,
259
259
  */
260
260
  static void
261
261
  maybe_decompress(lcb_t o,
262
- const packet_info *respkt, lcb_RESPGET *rescmd, void **freeptr)
262
+ const MemcachedResponse* respkt, lcb_RESPGET *rescmd, void **freeptr)
263
263
  {
264
264
  lcb_U8 dtype = 0;
265
- if (!PACKET_NVALUE(respkt)) {
265
+ if (!respkt->vallen()) {
266
266
  return;
267
267
  }
268
268
 
269
- if (PACKET_DATATYPE(respkt) & PROTOCOL_BINARY_DATATYPE_JSON) {
269
+ if (respkt->datatype() & PROTOCOL_BINARY_DATATYPE_JSON) {
270
270
  dtype = LCB_VALUE_F_JSON;
271
271
  }
272
272
 
273
- if (PACKET_DATATYPE(respkt) & PROTOCOL_BINARY_DATATYPE_COMPRESSED) {
273
+ if (respkt->datatype() & PROTOCOL_BINARY_DATATYPE_COMPRESSED) {
274
274
  if (LCBT_SETTING(o, compressopts) & LCB_COMPRESS_IN) {
275
275
  /* if we inflate, we don't set the flag */
276
276
  mcreq_inflate_value(
277
- PACKET_VALUE(respkt), PACKET_NVALUE(respkt),
277
+ respkt->value(), respkt->vallen(),
278
278
  &rescmd->value, &rescmd->nvalue, freeptr);
279
279
 
280
280
  } else {
@@ -286,7 +286,7 @@ maybe_decompress(lcb_t o,
286
286
  }
287
287
 
288
288
  static void
289
- H_get(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
289
+ H_get(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse* response,
290
290
  lcb_error_t immerr)
291
291
  {
292
292
  lcb_RESPGET resp = { 0 };
@@ -298,12 +298,12 @@ H_get(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
298
298
  if (resp.rc == LCB_SUCCESS) {
299
299
  const protocol_binary_response_get *get =
300
300
  reinterpret_cast<const protocol_binary_response_get*>(
301
- PACKET_EPHEMERAL_START(response));
302
- resp.datatype = PACKET_DATATYPE(response);
301
+ response->ephemeral_start());
302
+ resp.datatype = response->datatype();
303
303
  resp.itmflags = ntohl(get->message.body.flags);
304
- resp.value = PACKET_VALUE(response);
305
- resp.nvalue = PACKET_NVALUE(response);
306
- resp.bufh = response->bufh;
304
+ resp.value = response->value();
305
+ resp.nvalue = response->vallen();
306
+ resp.bufh = response->bufseg();
307
307
  }
308
308
 
309
309
  void *freeptr = NULL;
@@ -314,8 +314,8 @@ H_get(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
314
314
  }
315
315
 
316
316
  static void
317
- H_getreplica(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
318
- lcb_error_t immerr)
317
+ H_getreplica(mc_PIPELINE *pipeline, mc_PACKET *request,
318
+ MemcachedResponse *response, lcb_error_t immerr)
319
319
  {
320
320
  lcb_RESPGET resp = { 0 };
321
321
  lcb_t instance = get_instance(pipeline);
@@ -327,12 +327,12 @@ H_getreplica(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
327
327
  if (resp.rc == LCB_SUCCESS) {
328
328
  const protocol_binary_response_get *get =
329
329
  reinterpret_cast<const protocol_binary_response_get*>(
330
- PACKET_EPHEMERAL_START(response));
330
+ response->ephemeral_start());
331
331
  resp.itmflags = ntohl(get->message.body.flags);
332
- resp.datatype = PACKET_DATATYPE(response);
333
- resp.value = PACKET_VALUE(response);
334
- resp.nvalue = PACKET_NVALUE(response);
335
- resp.bufh = response->bufh;
332
+ resp.datatype = response->datatype();
333
+ resp.value = response->value();
334
+ resp.nvalue = response->vallen();
335
+ resp.bufh = response->bufseg();
336
336
  }
337
337
 
338
338
  maybe_decompress(instance, response, &resp, &freeptr);
@@ -341,8 +341,8 @@ H_getreplica(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
341
341
  }
342
342
 
343
343
  static void
344
- H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
345
- lcb_error_t immerr)
344
+ H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request,
345
+ MemcachedResponse *response, lcb_error_t immerr)
346
346
  {
347
347
  lcb_t o = get_instance(pipeline);
348
348
  ResponsePack<lcb_RESPSUBDOC> w = {{ 0 }};
@@ -351,7 +351,7 @@ H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
351
351
  w.resp.rflags |= LCB_RESP_F_FINAL;
352
352
 
353
353
  /* For mutations, add the mutation token */
354
- switch (PACKET_OPCODE(response)) {
354
+ switch (response->opcode()) {
355
355
  case PROTOCOL_BINARY_CMD_SUBDOC_GET:
356
356
  case PROTOCOL_BINARY_CMD_SUBDOC_EXISTS:
357
357
  case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP:
@@ -365,8 +365,8 @@ H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
365
365
  break;
366
366
  }
367
367
 
368
- if (PACKET_OPCODE(response) == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP ||
369
- PACKET_OPCODE(response) == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION) {
368
+ if (response->opcode() == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP ||
369
+ response->opcode() == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION) {
370
370
  if (w.resp.rc == LCB_SUCCESS || w.resp.rc == LCB_SUBDOC_MULTI_FAILURE) {
371
371
  w.resp.responses = response;
372
372
  }
@@ -384,17 +384,17 @@ H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
384
384
  }
385
385
 
386
386
  static int
387
- sdlookup_next(const packet_info *response, lcb_SDENTRY *ent, size_t *iter)
387
+ sdlookup_next(const MemcachedResponse *response, lcb_SDENTRY *ent, size_t *iter)
388
388
  {
389
389
  const char *buf;
390
390
  uint16_t rc;
391
391
  uint32_t vlen;
392
392
 
393
- if (*iter == PACKET_NVALUE(response)) {
393
+ if (*iter == response->vallen()) {
394
394
  return 0;
395
395
  }
396
396
 
397
- buf = PACKET_VALUE(response);
397
+ buf = response->value();
398
398
  buf += *iter;
399
399
 
400
400
  memcpy(&rc, buf, 2);
@@ -418,18 +418,18 @@ sdlookup_next(const packet_info *response, lcb_SDENTRY *ent, size_t *iter)
418
418
  }
419
419
 
420
420
  static int
421
- sdmutate_next(const packet_info *response, lcb_SDENTRY *ent, size_t *iter)
421
+ sdmutate_next(const MemcachedResponse *response, lcb_SDENTRY *ent, size_t *iter)
422
422
  {
423
423
  const char *buf, *buf_end;
424
424
  uint16_t rc;
425
425
  uint32_t vlen;
426
426
 
427
- if (*iter == PACKET_NVALUE(response)) {
427
+ if (*iter == response->vallen()) {
428
428
  return 0;
429
429
  }
430
430
 
431
- buf_end = (const char *)PACKET_VALUE(response) + PACKET_NVALUE(response);
432
- buf = ((const char *)(PACKET_VALUE(response))) + *iter;
431
+ buf_end = (const char *)response->value() + response->vallen();
432
+ buf = ((const char *)(response->value())) + *iter;
433
433
 
434
434
  #define ADVANCE_BUF(sz) \
435
435
  buf += sz; \
@@ -470,7 +470,8 @@ int
470
470
  lcb_sdresult_next(const lcb_RESPSUBDOC *resp, lcb_SDENTRY *ent, size_t *iter)
471
471
  {
472
472
  size_t iter_s = 0;
473
- const packet_info *response = (const packet_info*)resp->responses;
473
+ const MemcachedResponse *response =
474
+ reinterpret_cast<const MemcachedResponse*>(resp->responses);
474
475
  if (!response) {
475
476
  return 0;
476
477
  }
@@ -479,7 +480,7 @@ lcb_sdresult_next(const lcb_RESPSUBDOC *resp, lcb_SDENTRY *ent, size_t *iter)
479
480
  iter = &iter_s;
480
481
  }
481
482
 
482
- switch (PACKET_OPCODE(response)) {
483
+ switch (response->opcode()) {
483
484
  case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP:
484
485
  return sdlookup_next(response, ent, iter);
485
486
  case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION:
@@ -491,9 +492,9 @@ lcb_sdresult_next(const lcb_RESPSUBDOC *resp, lcb_SDENTRY *ent, size_t *iter)
491
492
  *iter = 1;
492
493
 
493
494
  if (resp->rc == LCB_SUCCESS || resp->rc == LCB_SUBDOC_MULTI_FAILURE) {
494
- ent->status = map_error(NULL, PACKET_STATUS(response));
495
- ent->value = PACKET_VALUE(response);
496
- ent->nvalue = PACKET_NVALUE(response);
495
+ ent->status = map_error(NULL, response->status());
496
+ ent->value = response->value();
497
+ ent->nvalue = response->vallen();
497
498
  ent->index = 0;
498
499
  return 1;
499
500
  } else {
@@ -503,7 +504,7 @@ lcb_sdresult_next(const lcb_RESPSUBDOC *resp, lcb_SDENTRY *ent, size_t *iter)
503
504
  }
504
505
 
505
506
  static void
506
- H_delete(mc_PIPELINE *pipeline, mc_PACKET *packet, packet_info *response,
507
+ H_delete(mc_PIPELINE *pipeline, mc_PACKET *packet, MemcachedResponse *response,
507
508
  lcb_error_t immerr)
508
509
  {
509
510
  lcb_t root = get_instance(pipeline);
@@ -516,7 +517,7 @@ H_delete(mc_PIPELINE *pipeline, mc_PACKET *packet, packet_info *response,
516
517
  }
517
518
 
518
519
  static void
519
- H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
520
+ H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response,
520
521
  lcb_error_t immerr)
521
522
  {
522
523
  lcb_t root = get_instance(pipeline);
@@ -537,7 +538,8 @@ H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
537
538
  }
538
539
 
539
540
  /** The CAS field is split into TTP/TTR values */
540
- ptr = (char *)&response->res.response.cas;
541
+ uint64_t tmpcas = lcb_htonll(response->cas());
542
+ ptr = reinterpret_cast<char*>(&tmpcas);
541
543
  memcpy(&ttp, ptr, sizeof(ttp));
542
544
  memcpy(&ttr, ptr + sizeof(ttp), sizeof(ttp));
543
545
 
@@ -545,8 +547,8 @@ H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
545
547
  ttr = ntohl(ttr);
546
548
 
547
549
  /** Actual payload sequence of (vb, nkey, key). Repeats multiple times */
548
- ptr = reinterpret_cast<const char *>(response->payload);
549
- end = (char *)ptr + PACKET_NBODY(response);
550
+ ptr = response->body<const char *>();
551
+ end = ptr + response->bodylen();
550
552
  config = pipeline->parent->config;
551
553
 
552
554
  for (pos = 0; ptr < end; pos++) {
@@ -585,8 +587,7 @@ H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
585
587
 
586
588
  static void
587
589
  H_observe_seqno(mc_PIPELINE *pipeline, mc_PACKET *request,
588
- packet_info *response, lcb_error_t immerr)
589
- {
590
+ MemcachedResponse *response, lcb_error_t immerr) {
590
591
  lcb_t root = get_instance(pipeline);
591
592
  lcb_RESPOBSEQNO resp = { 0 };
592
593
  init_resp(root, response, request, immerr, &resp);
@@ -594,7 +595,7 @@ H_observe_seqno(mc_PIPELINE *pipeline, mc_PACKET *request,
594
595
  resp.server_index = pipeline->index;
595
596
 
596
597
  if (resp.rc == LCB_SUCCESS) {
597
- const uint8_t *data = reinterpret_cast<const uint8_t*>(PACKET_BODY(response));
598
+ const uint8_t *data = response->body<const uint8_t*>();
598
599
  bool is_failover = *data != 0;
599
600
 
600
601
  data++;
@@ -620,7 +621,7 @@ H_observe_seqno(mc_PIPELINE *pipeline, mc_PACKET *request,
620
621
  }
621
622
 
622
623
  static void
623
- H_store(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
624
+ H_store(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response,
624
625
  lcb_error_t immerr)
625
626
  {
626
627
  lcb_t root = get_instance(pipeline);
@@ -628,7 +629,7 @@ H_store(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
628
629
  uint8_t opcode;
629
630
  init_resp(root, response, request, immerr, &w.resp);
630
631
  if (!immerr) {
631
- opcode = PACKET_OPCODE(response);
632
+ opcode = response->opcode();
632
633
  } else {
633
634
  protocol_binary_request_header hdr;
634
635
  mcreq_read_hdr(request, &hdr);
@@ -656,28 +657,28 @@ H_store(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
656
657
  }
657
658
 
658
659
  static void
659
- H_arithmetic(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
660
- lcb_error_t immerr)
660
+ H_arithmetic(mc_PIPELINE *pipeline, mc_PACKET *request,
661
+ MemcachedResponse *response, lcb_error_t immerr)
661
662
  {
662
663
  lcb_t root = get_instance(pipeline);
663
664
  ResponsePack<lcb_RESPCOUNTER> w = { { 0 } };
664
665
  init_resp(root, response, request, immerr, &w.resp);
665
666
 
666
667
  if (w.resp.rc == LCB_SUCCESS) {
667
- memcpy(&w.resp.value, PACKET_VALUE(response), sizeof(w.resp.value));
668
+ memcpy(&w.resp.value, response->value(), sizeof(w.resp.value));
668
669
  w.resp.value = lcb_ntohll(w.resp.value);
669
670
  w.resp.rflags |= LCB_RESP_F_EXTDATA;
670
671
  handle_mutation_token(root, response, request, &w.mt);
671
672
  }
672
673
  w.resp.rflags |= LCB_RESP_F_FINAL;
673
- w.resp.cas = PACKET_CAS(response);
674
+ w.resp.cas = response->cas();
674
675
  TRACE_ARITHMETIC_END(response, &w.resp);
675
676
  invoke_callback(request, root, &w.resp, LCB_CALLBACK_COUNTER);
676
677
  }
677
678
 
678
679
  static void
679
- H_stats(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
680
- lcb_error_t immerr)
680
+ H_stats(mc_PIPELINE *pipeline, mc_PACKET *request,
681
+ MemcachedResponse *response, lcb_error_t immerr)
681
682
  {
682
683
  lcb_t root = get_instance(pipeline);
683
684
  lcb_RESPSTATS resp = { 0 };
@@ -687,17 +688,17 @@ H_stats(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
687
688
  resp.version = 0;
688
689
 
689
690
  exdata = request->u_rdata.exdata;
690
- if (resp.rc != LCB_SUCCESS || PACKET_NKEY(response) == 0) {
691
+ if (resp.rc != LCB_SUCCESS || response->keylen() == 0) {
691
692
  /* Call the handler without a response, this indicates that this server
692
693
  * has finished responding */
693
694
  exdata->procs->handler(pipeline, request, resp.rc, NULL);
694
695
  return;
695
696
  }
696
697
 
697
- if ((resp.nkey = PACKET_NKEY(response))) {
698
- resp.key = PACKET_KEY(response);
699
- if ((resp.value = PACKET_VALUE(response))) {
700
- resp.nvalue = PACKET_NVALUE(response);
698
+ if ((resp.nkey = response->keylen())) {
699
+ resp.key = response->key();
700
+ if ((resp.value = response->value())) {
701
+ resp.nvalue = response->vallen();
701
702
  }
702
703
  }
703
704
 
@@ -705,8 +706,8 @@ H_stats(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
705
706
  }
706
707
 
707
708
  static void
708
- H_verbosity(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
709
- lcb_error_t immerr)
709
+ H_verbosity(mc_PIPELINE *pipeline, mc_PACKET *request,
710
+ MemcachedResponse *response, lcb_error_t immerr)
710
711
  {
711
712
  lcb_t root = get_instance(pipeline);
712
713
  lcb_RESPBASE dummy = { 0 };
@@ -717,8 +718,8 @@ H_verbosity(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
717
718
  }
718
719
 
719
720
  static void
720
- H_version(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
721
- lcb_error_t immerr)
721
+ H_version(mc_PIPELINE *pipeline, mc_PACKET *request,
722
+ MemcachedResponse *response, lcb_error_t immerr)
722
723
  {
723
724
  lcb_t root = get_instance(pipeline);
724
725
  lcb_RESPMCVERSION resp = { 0 };
@@ -726,9 +727,9 @@ H_version(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
726
727
 
727
728
  make_error(root, &resp, response, immerr);
728
729
 
729
- if (PACKET_NBODY(response)) {
730
- resp.mcversion = reinterpret_cast<const char *>(response->payload);
731
- resp.nversion = PACKET_NBODY(response);
730
+ if (response->bodylen()) {
731
+ resp.mcversion = response->body<const char *>();
732
+ resp.nversion = response->bodylen();
732
733
  }
733
734
 
734
735
 
@@ -736,7 +737,7 @@ H_version(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
736
737
  }
737
738
 
738
739
  static void
739
- H_touch(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
740
+ H_touch(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response,
740
741
  lcb_error_t immerr)
741
742
  {
742
743
  lcb_t root = get_instance(pipeline);
@@ -748,7 +749,7 @@ H_touch(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
748
749
  }
749
750
 
750
751
  static void
751
- H_flush(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
752
+ H_flush(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response,
752
753
  lcb_error_t immerr)
753
754
  {
754
755
  lcb_t root = get_instance(pipeline);
@@ -759,7 +760,7 @@ H_flush(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
759
760
  }
760
761
 
761
762
  static void
762
- H_unlock(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
763
+ H_unlock(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response,
763
764
  lcb_error_t immerr)
764
765
  {
765
766
  lcb_t root = get_instance(pipeline);
@@ -771,7 +772,7 @@ H_unlock(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
771
772
  }
772
773
 
773
774
  static void
774
- H_config(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
775
+ H_config(mc_PIPELINE *pipeline, mc_PACKET *request, MemcachedResponse *response,
775
776
  lcb_error_t immerr)
776
777
  {
777
778
  /** We just jump to the normal config handler */
@@ -783,7 +784,7 @@ H_config(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
783
784
  }
784
785
 
785
786
  static void
786
- record_metrics(mc_PIPELINE *pipeline, mc_PACKET *req, packet_info *)
787
+ record_metrics(mc_PIPELINE *pipeline, mc_PACKET *req, MemcachedResponse *)
787
788
  {
788
789
  lcb_t instance = get_instance(pipeline);
789
790
  if (instance->kv_timings) {
@@ -796,7 +797,7 @@ static void
796
797
  dispatch_ufwd_error(mc_PIPELINE *pipeline, mc_PACKET *req, lcb_error_t immerr)
797
798
  {
798
799
  lcb_PKTFWDRESP resp = { 0 };
799
- lcb_t instance = ((mc_SERVER*)pipeline)->instance;
800
+ lcb_t instance = static_cast<lcb::Server*>(pipeline)->get_instance();
800
801
  assert(immerr != LCB_SUCCESS);
801
802
  resp.version = 0;
802
803
  instance->callbacks.pktfwd(instance, MCREQ_PKT_COOKIE(req), immerr, &resp);
@@ -804,7 +805,7 @@ dispatch_ufwd_error(mc_PIPELINE *pipeline, mc_PACKET *req, lcb_error_t immerr)
804
805
 
805
806
  int
806
807
  mcreq_dispatch_response(
807
- mc_PIPELINE *pipeline, mc_PACKET *req, packet_info *res,
808
+ mc_PIPELINE *pipeline, mc_PACKET *req, MemcachedResponse *res,
808
809
  lcb_error_t immerr)
809
810
  {
810
811
  record_metrics(pipeline, req, res);
@@ -820,9 +821,7 @@ mcreq_dispatch_response(
820
821
  return 0; \
821
822
  break;
822
823
 
823
- switch (PACKET_OPCODE(res)) {
824
- case PROTOCOL_BINARY_CMD_GETQ:
825
- case PROTOCOL_BINARY_CMD_GATQ:
824
+ switch (res->opcode()) {
826
825
  case PROTOCOL_BINARY_CMD_GET:
827
826
  case PROTOCOL_BINARY_CMD_GAT:
828
827
  case PROTOCOL_BINARY_CMD_GET_LOCKED:
@@ -894,7 +893,7 @@ mcreq_dispatch_response(
894
893
  INVOKE_OP(H_config);
895
894
 
896
895
  default:
897
- fprintf(stderr, "COUCHBASE: Received unknown opcode=0x%x\n", PACKET_OPCODE(res));
896
+ fprintf(stderr, "COUCHBASE: Received unknown opcode=0x%x\n", res->opcode());
898
897
  return -1;
899
898
  }
900
899
  }