libcouchbase 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/README.md +1 -1
  4. data/ext/libcouchbase/CMakeLists.txt +8 -6
  5. data/ext/libcouchbase/README.markdown +2 -2
  6. data/ext/libcouchbase/RELEASE_NOTES.markdown +0 -86
  7. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +0 -11
  8. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +0 -2
  9. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +1 -2
  10. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  11. data/ext/libcouchbase/cmake/config-cmake.h.in +0 -2
  12. data/ext/libcouchbase/cmake/defs.mk.in +2 -0
  13. data/ext/libcouchbase/cmake/source_files.cmake +5 -21
  14. data/ext/libcouchbase/include/libcouchbase/auth.h +0 -10
  15. data/ext/libcouchbase/include/libcouchbase/cntl.h +1 -27
  16. data/ext/libcouchbase/include/libcouchbase/error.h +1 -15
  17. data/ext/libcouchbase/include/libcouchbase/n1ql.h +1 -13
  18. data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +1 -1
  19. data/ext/libcouchbase/include/libcouchbase/subdoc.h +0 -9
  20. data/ext/libcouchbase/include/libcouchbase/views.h +1 -7
  21. data/ext/libcouchbase/include/libcouchbase/visibility.h +0 -1
  22. data/ext/libcouchbase/include/memcached/protocol_binary.h +1131 -29
  23. data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
  24. data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
  25. data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +2 -3
  26. data/ext/libcouchbase/src/README.md +2 -0
  27. data/ext/libcouchbase/src/auth-priv.h +0 -1
  28. data/ext/libcouchbase/src/auth.cc +4 -10
  29. data/ext/libcouchbase/src/bootstrap.c +269 -0
  30. data/ext/libcouchbase/src/bootstrap.h +39 -50
  31. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +117 -84
  32. data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
  33. data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
  34. data/ext/libcouchbase/src/bucketconfig/bc_http.h +25 -50
  35. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
  36. data/ext/libcouchbase/src/bucketconfig/clconfig.h +386 -407
  37. data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
  38. data/ext/libcouchbase/src/cbft.cc +27 -22
  39. data/ext/libcouchbase/src/cntl.cc +19 -30
  40. data/ext/libcouchbase/src/connspec.cc +1 -48
  41. data/ext/libcouchbase/src/connspec.h +0 -27
  42. data/ext/libcouchbase/src/dump.cc +2 -2
  43. data/ext/libcouchbase/src/getconfig.cc +33 -7
  44. data/ext/libcouchbase/src/handler.cc +2 -0
  45. data/ext/libcouchbase/src/hostlist.cc +36 -0
  46. data/ext/libcouchbase/src/hostlist.h +62 -41
  47. data/ext/libcouchbase/src/http/http-priv.h +112 -125
  48. data/ext/libcouchbase/src/http/http.cc +30 -15
  49. data/ext/libcouchbase/src/http/http.h +34 -1
  50. data/ext/libcouchbase/src/http/http_io.cc +26 -22
  51. data/ext/libcouchbase/src/instance.cc +23 -94
  52. data/ext/libcouchbase/src/internal.h +26 -52
  53. data/ext/libcouchbase/src/jsparse/parser.cc +202 -146
  54. data/ext/libcouchbase/src/jsparse/parser.h +98 -91
  55. data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
  56. data/ext/libcouchbase/src/lcbht/lcbht.h +163 -174
  57. data/ext/libcouchbase/src/lcbio/connect.c +557 -0
  58. data/ext/libcouchbase/src/lcbio/connect.h +2 -9
  59. data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
  60. data/ext/libcouchbase/src/lcbio/iotable.h +16 -61
  61. data/ext/libcouchbase/src/lcbio/ioutils.h +1 -1
  62. data/ext/libcouchbase/src/lcbio/manager.c +2 -2
  63. data/ext/libcouchbase/src/mc/mcreq.h +2 -9
  64. data/ext/libcouchbase/src/mcserver/mcserver.cc +34 -143
  65. data/ext/libcouchbase/src/mcserver/mcserver.h +12 -7
  66. data/ext/libcouchbase/src/mcserver/negotiate.cc +38 -132
  67. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
  68. data/ext/libcouchbase/src/n1ql/n1ql.cc +32 -56
  69. data/ext/libcouchbase/src/newconfig.cc +6 -6
  70. data/ext/libcouchbase/src/nodeinfo.cc +2 -2
  71. data/ext/libcouchbase/src/operations/{cbflush.cc → cbflush.c} +15 -7
  72. data/ext/libcouchbase/src/operations/{counter.cc → counter.c} +0 -0
  73. data/ext/libcouchbase/src/operations/durability.cc +26 -6
  74. data/ext/libcouchbase/src/operations/durability_internal.h +3 -6
  75. data/ext/libcouchbase/src/operations/{get.cc → get.c} +26 -24
  76. data/ext/libcouchbase/src/operations/{observe.cc → observe.c} +93 -68
  77. data/ext/libcouchbase/src/operations/{pktfwd.cc → pktfwd.c} +0 -0
  78. data/ext/libcouchbase/src/operations/{remove.cc → remove.c} +0 -0
  79. data/ext/libcouchbase/src/operations/stats.cc +8 -3
  80. data/ext/libcouchbase/src/operations/{store.cc → store.c} +32 -27
  81. data/ext/libcouchbase/src/operations/subdoc.cc +18 -38
  82. data/ext/libcouchbase/src/operations/{touch.cc → touch.c} +0 -0
  83. data/ext/libcouchbase/src/packetutils.c +37 -0
  84. data/ext/libcouchbase/src/packetutils.h +2 -2
  85. data/ext/libcouchbase/src/probes.d +1 -1
  86. data/ext/libcouchbase/src/{retrychk.cc → retrychk.c} +3 -2
  87. data/ext/libcouchbase/src/retryq.cc +4 -4
  88. data/ext/libcouchbase/src/settings.c +0 -3
  89. data/ext/libcouchbase/src/settings.h +0 -5
  90. data/ext/libcouchbase/src/simplestring.c +211 -0
  91. data/ext/libcouchbase/src/simplestring.h +228 -0
  92. data/ext/libcouchbase/src/ssl/ssl_c.c +0 -1
  93. data/ext/libcouchbase/src/ssl/ssl_common.c +0 -2
  94. data/ext/libcouchbase/src/ssl/ssl_e.c +1 -0
  95. data/ext/libcouchbase/src/ssobuf.h +82 -0
  96. data/ext/libcouchbase/src/trace.h +4 -4
  97. data/ext/libcouchbase/src/vbucket/vbucket.c +1 -0
  98. data/ext/libcouchbase/src/views/{docreq.cc → docreq.c} +54 -48
  99. data/ext/libcouchbase/src/views/docreq.h +30 -24
  100. data/ext/libcouchbase/src/views/viewreq.c +358 -0
  101. data/ext/libcouchbase/src/views/viewreq.h +13 -43
  102. data/ext/libcouchbase/tests/basic/t_connstr.cc +50 -89
  103. data/ext/libcouchbase/tests/basic/t_host.cc +75 -67
  104. data/ext/libcouchbase/tests/basic/t_jsparse.cc +78 -27
  105. data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
  106. data/ext/libcouchbase/tests/htparse/t_basic.cc +78 -58
  107. data/ext/libcouchbase/tests/iotests/mock-environment.h +1 -2
  108. data/ext/libcouchbase/tests/iotests/t_confmon.cc +114 -96
  109. data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
  110. data/ext/libcouchbase/tools/cbc-pillowfight.cc +1 -1
  111. data/lib/libcouchbase/ext/tasks.rb +6 -2
  112. data/lib/libcouchbase/query_view.rb +1 -1
  113. data/lib/libcouchbase/results_fiber.rb +6 -6
  114. data/lib/libcouchbase/version.rb +1 -1
  115. metadata +26 -26
  116. data/ext/libcouchbase/src/bootstrap.cc +0 -216
  117. data/ext/libcouchbase/src/bucketconfig/bc_file.cc +0 -281
  118. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +0 -528
  119. data/ext/libcouchbase/src/bucketconfig/bc_mcraw.cc +0 -115
  120. data/ext/libcouchbase/src/bucketconfig/confmon.cc +0 -378
  121. data/ext/libcouchbase/src/dns-srv.cc +0 -142
  122. data/ext/libcouchbase/src/errmap.cc +0 -107
  123. data/ext/libcouchbase/src/errmap.h +0 -113
  124. data/ext/libcouchbase/src/lcbht/lcbht.cc +0 -177
  125. data/ext/libcouchbase/src/lcbio/connect.cc +0 -562
  126. data/ext/libcouchbase/src/lcbio/timer-cxx.h +0 -87
  127. data/ext/libcouchbase/src/mctx-helper.h +0 -51
  128. data/ext/libcouchbase/src/views/viewreq.cc +0 -318
  129. data/ext/libcouchbase/tests/iotests/t_errmap.cc +0 -97
@@ -22,9 +22,14 @@ struct BcastCookie : mc_REQDATAEX {
22
22
  int remaining;
23
23
 
24
24
  BcastCookie(lcb_CALLBACKTYPE type_,
25
- const mc_REQDATAPROCS* procs_, const void *cookie_)
26
- : mc_REQDATAEX(cookie_, *procs_, gethrtime()),
27
- type(type_), remaining(0) {
25
+ mc_REQDATAPROCS* procs_,
26
+ const void *cookie_) {
27
+
28
+ mc_REQDATAEX::procs = procs_;
29
+ mc_REQDATAEX::cookie = cookie_;
30
+ mc_REQDATAEX::start = gethrtime();
31
+ type = type_;
32
+ remaining = 0;
28
33
  }
29
34
  };
30
35
 
@@ -19,30 +19,23 @@
19
19
  #include "trace.h"
20
20
  #include "durability_internal.h"
21
21
 
22
- struct DurStoreCtx : mc_REQDATAEX {
22
+ typedef struct {
23
+ mc_REQDATAEX base;
23
24
  lcb_t instance;
24
25
  lcb_U16 persist_to;
25
26
  lcb_U16 replicate_to;
26
-
27
- static mc_REQDATAPROCS proctable;
28
-
29
- DurStoreCtx(lcb_t instance_, lcb_U16 persist_, lcb_U16 replicate_,
30
- const void *cookie_)
31
- : mc_REQDATAEX(cookie_, proctable, gethrtime()),
32
- instance(instance_), persist_to(persist_), replicate_to(replicate_) {
33
- }
34
- };
27
+ } DURSTORECTX;
35
28
 
36
29
  /** Observe stuff */
37
30
  static void
38
- handle_dur_storecb(mc_PIPELINE *, mc_PACKET *pkt,
31
+ handle_dur_storecb(mc_PIPELINE *pl, mc_PACKET *pkt,
39
32
  lcb_error_t err, const void *arg)
40
33
  {
41
34
  lcb_RESPCALLBACK cb;
42
35
  lcb_RESPSTOREDUR resp = { 0 };
43
36
  lcb_CMDENDURE dcmd = { 0 };
44
37
  const lcb_MUTATION_TOKEN *mt;
45
- DurStoreCtx *dctx = static_cast<DurStoreCtx*>(pkt->u_rdata.exdata);
38
+ DURSTORECTX *dctx = (DURSTORECTX *)pkt->u_rdata.exdata;
46
39
  lcb_MULTICMD_CTX *mctx;
47
40
  lcb_durability_opts_t opts = { 0 };
48
41
  const lcb_RESPSTORE *sresp = (const lcb_RESPSTORE *)arg;
@@ -85,7 +78,7 @@ handle_dur_storecb(mc_PIPELINE *, mc_PACKET *pkt,
85
78
 
86
79
  if (err == LCB_SUCCESS) {
87
80
  /* Everything OK? */
88
- delete dctx;
81
+ free(dctx);
89
82
  return;
90
83
  }
91
84
 
@@ -99,15 +92,20 @@ handle_dur_storecb(mc_PIPELINE *, mc_PACKET *pkt,
99
92
  resp.dur_resp = &dresp;
100
93
  cb = lcb_find_callback(dctx->instance, LCB_CALLBACK_STOREDUR);
101
94
  cb(dctx->instance, LCB_CALLBACK_STOREDUR, (const lcb_RESPBASE*)&resp);
102
- delete dctx;
95
+ free(dctx);
103
96
  }
97
+
98
+ (void)pl;
104
99
  }
105
100
 
106
- static void handle_dur_schedfail(mc_PACKET *pkt) {
107
- delete static_cast<DurStoreCtx*>(pkt->u_rdata.exdata);
101
+ static void
102
+ handle_dur_schedfail(mc_PACKET *pkt)
103
+ {
104
+ DURSTORECTX *dctx = (void *)pkt->u_rdata.exdata;
105
+ free(dctx);
108
106
  }
109
107
 
110
- mc_REQDATAPROCS DurStoreCtx::proctable = {
108
+ mc_REQDATAPROCS storedur_procs = {
111
109
  handle_dur_storecb,
112
110
  handle_dur_schedfail
113
111
  };
@@ -152,7 +150,7 @@ static int
152
150
  can_compress(lcb_t instance, const mc_PIPELINE *pipeline,
153
151
  const lcb_VALBUF *vbuf, lcb_datatype_t datatype)
154
152
  {
155
- const lcb::Server *server = static_cast<const lcb::Server*>(pipeline);
153
+ mc_SERVER *server = (mc_SERVER *)pipeline;
156
154
  int compressopts = LCBT_SETTING(instance, compressopts);
157
155
 
158
156
  if (mcreq_compression_supported() == 0) {
@@ -165,8 +163,7 @@ can_compress(lcb_t instance, const mc_PIPELINE *pipeline,
165
163
  if ((compressopts & LCB_COMPRESS_OUT) == 0) {
166
164
  return 0;
167
165
  }
168
- if (server->supports_compression() == false &&
169
- (compressopts & LCB_COMPRESS_FORCE) == 0) {
166
+ if (mcserver_supports_compression(server) == 0 && (compressopts & LCB_COMPRESS_FORCE) == 0) {
170
167
  return 0;
171
168
  }
172
169
  if (datatype & LCB_VALUE_F_SNAPPYCOMP) {
@@ -181,6 +178,7 @@ do_store3(lcb_t instance, const void *cookie,
181
178
  {
182
179
  mc_PIPELINE *pipeline;
183
180
  mc_PACKET *packet;
181
+ mc_REQDATA *rdata;
184
182
  mc_CMDQUEUE *cq = &instance->cmdq;
185
183
  int hsize;
186
184
  int should_compress = 0;
@@ -258,6 +256,8 @@ do_store3(lcb_t instance, const void *cookie,
258
256
  int duropts = 0;
259
257
  lcb_U16 persist_u , replicate_u;
260
258
  const lcb_CMDSTOREDUR *dcmd = (const lcb_CMDSTOREDUR *)cmd;
259
+ DURSTORECTX *dctx = calloc(1, sizeof(*dctx));
260
+
261
261
  persist_u = dcmd->persist_to;
262
262
  replicate_u = dcmd->replicate_to;
263
263
  if (dcmd->replicate_to == -1 || dcmd->persist_to == -1) {
@@ -268,19 +268,24 @@ do_store3(lcb_t instance, const void *cookie,
268
268
  if (err != LCB_SUCCESS) {
269
269
  mcreq_wipe_packet(pipeline, packet);
270
270
  mcreq_release_packet(pipeline, packet);
271
+ free(dctx);
271
272
  return err;
272
273
  }
273
274
 
274
- DurStoreCtx *dctx = new DurStoreCtx(instance, persist_u, replicate_u,
275
- cookie);
276
- packet->u_rdata.exdata = dctx;
275
+ dctx->instance = instance;
276
+ dctx->persist_to = persist_u;
277
+ dctx->replicate_to = replicate_u;
278
+ packet->u_rdata.exdata = &dctx->base;
277
279
  packet->flags |= MCREQ_F_REQEXT;
278
- } else {
279
- mc_REQDATA *rdata = MCREQ_PKT_RDATA(packet);
280
- rdata->cookie = cookie;
281
- rdata->start = gethrtime();
280
+
281
+ dctx->base.cookie = cookie;
282
+ dctx->base.procs = &storedur_procs;
282
283
  }
283
284
 
285
+ rdata = MCREQ_PKT_RDATA(packet);
286
+ rdata->cookie = cookie;
287
+ rdata->start = gethrtime();
288
+
284
289
  scmd.message.body.expiration = htonl(cmd->exptime);
285
290
  scmd.message.body.flags = htonl(flags);
286
291
  hdr->request.magic = PROTOCOL_BINARY_REQ;
@@ -58,17 +58,6 @@ struct Traits {
58
58
  return is_lookup ? LCB_SDMULTI_MODE_LOOKUP : LCB_SDMULTI_MODE_MUTATE;
59
59
  }
60
60
 
61
- inline bool chk_allow_empty_path(uint32_t options) const {
62
- if (allow_empty_path) {
63
- return true;
64
- }
65
- if (!is_lookup) {
66
- return false;
67
- }
68
-
69
- return (options & LCB_SDSPEC_F_XATTRPATH) != 0;
70
- }
71
-
72
61
  inline Traits(uint8_t op, unsigned options) :
73
62
  allow_empty_path(options & EMPTY_PATH),
74
63
  allow_expiry(options & ALLOW_EXPIRY),
@@ -174,28 +163,6 @@ get_valbuf_size(const lcb_VALBUF& vb)
174
163
  }
175
164
  }
176
165
 
177
- static uint8_t
178
- make_subdoc_flags(const uint32_t user)
179
- {
180
- uint8_t subdoc_flags = 0;
181
- if (user & LCB_SDSPEC_F_MKINTERMEDIATES) {
182
- subdoc_flags |= SUBDOC_FLAG_MKDIR_P;
183
- }
184
- if (user & LCB_SDSPEC_F_MKDOCUMENT) {
185
- subdoc_flags |= SUBDOC_FLAG_MKDOC;
186
- }
187
- if (user & LCB_SDSPEC_F_XATTRPATH) {
188
- subdoc_flags |= SUBDOC_FLAG_XATTR_PATH;
189
- }
190
- if (user & LCB_SDSPEC_F_XATTR_MACROVALUES) {
191
- subdoc_flags |= (SUBDOC_FLAG_EXPAND_MACROS | SUBDOC_FLAG_XATTR_PATH);
192
- }
193
- if (user & LCB_SDSPEC_F_XATTR_DELETED_OK) {
194
- subdoc_flags |= (SUBDOC_FLAG_XATTR_PATH|SUBDOC_FLAG_ACCESS_DELETED);
195
- }
196
- return subdoc_flags;
197
- }
198
-
199
166
  struct MultiBuilder {
200
167
  MultiBuilder(const lcb_CMDSUBDOC *cmd_)
201
168
  : cmd(cmd_), payload_size(0), mode(0) {
@@ -299,10 +266,17 @@ MultiBuilder::add_spec(const lcb_SDSPEC *spec)
299
266
  // opcode
300
267
  add_field(trait.opcode, 1);
301
268
  // flags
302
- add_field(make_subdoc_flags(spec->options), 1);
269
+ uint8_t sdflags = 0;
270
+ if (spec->options & LCB_SDSPEC_F_MKINTERMEDIATES) {
271
+ sdflags = SUBDOC_FLAG_MKDIR_P;
272
+ }
273
+ if (spec->options & LCB_SDSPEC_F_MKDOCUMENT) {
274
+ sdflags |= SUBDOC_FLAG_MKDOC;
275
+ }
276
+ add_field(sdflags, 1);
303
277
 
304
278
  uint16_t npath = static_cast<uint16_t>(spec->path.contig.nbytes);
305
- if (!npath && !trait.chk_allow_empty_path(spec->options)) {
279
+ if (!npath && !trait.allow_empty_path) {
306
280
  return LCB_EMPTY_PATH;
307
281
  }
308
282
 
@@ -355,8 +329,7 @@ sd3_single(lcb_t instance, const void *cookie, const lcb_CMDSUBDOC *cmd)
355
329
  if (LCB_KEYBUF_IS_EMPTY(&cmd->key)) {
356
330
  return LCB_EMPTY_KEY;
357
331
  }
358
- if (LCB_KEYBUF_IS_EMPTY(&spec->path) &&
359
- !traits.chk_allow_empty_path(spec->options)) {
332
+ if (LCB_KEYBUF_IS_EMPTY(&spec->path) && !traits.allow_empty_path) {
360
333
  return LCB_EMPTY_PATH;
361
334
  }
362
335
 
@@ -426,7 +399,14 @@ sd3_single(lcb_t instance, const void *cookie, const lcb_CMDSUBDOC *cmd)
426
399
  ntohs(hdr->request.keylen) + get_value_size(packet));
427
400
 
428
401
  request.message.extras.pathlen = htons(spec->path.contig.nbytes);
429
- request.message.extras.subdoc_flags = make_subdoc_flags(spec->options);
402
+ request.message.extras.subdoc_flags = 0;
403
+
404
+ if (spec->options & LCB_SDSPEC_F_MKINTERMEDIATES) {
405
+ request.message.extras.subdoc_flags |= SUBDOC_FLAG_MKDIR_P;
406
+ }
407
+ if (spec->options & LCB_SDSPEC_F_MKDOCUMENT) {
408
+ request.message.extras.subdoc_flags |= SUBDOC_FLAG_MKDOC;
409
+ }
430
410
 
431
411
  hdr->request.opcode = traits.opcode;
432
412
  memcpy(SPAN_BUFFER(&packet->kh_span), request.bytes, sizeof request.bytes);
@@ -0,0 +1,37 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2014 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include "packetutils.h"
19
+ #include "rdb/rope.h"
20
+
21
+ #ifndef _WIN32 /* for win32 this is inside winsock, included in sysdefs.h */
22
+ #include <arpa/inet.h>
23
+ #endif
24
+
25
+ int
26
+ lcb_pktinfo_ior_get(packet_info *info, rdb_IOROPE *ior, unsigned *required)
27
+ {
28
+ }
29
+
30
+ void
31
+ lcb_pktinfo_ior_done(packet_info *info, rdb_IOROPE *ior)
32
+ {
33
+ if (!PACKET_NBODY(info)) {
34
+ return;
35
+ }
36
+ rdb_consumed(ior, PACKET_NBODY(info));
37
+ }
@@ -43,8 +43,8 @@ public:
43
43
  }
44
44
 
45
45
  MemcachedResponse(protocol_binary_command cmd, uint32_t opaque_,
46
- protocol_binary_response_status code)
47
- : res(), payload(NULL), bufh(NULL) {
46
+ protocol_binary_response_status code) {
47
+ std::memset(this, 0, sizeof *this);
48
48
  res.response.opcode = cmd;
49
49
  res.response.opaque = opaque_;
50
50
  res.response.status = htons(code);
@@ -28,7 +28,7 @@ provider libcouchbase {
28
28
  uint16_t, /* return code (from libcouchbase) */
29
29
  const char*, /* key */
30
30
  size_t, /* nkey */
31
- const char*, /* bytes */
31
+ const void*, /* bytes */
32
32
  size_t, /* nbytes */
33
33
  uint32_t, /* flags */
34
34
  uint64_t, /* cas */
@@ -20,8 +20,8 @@
20
20
  int
21
21
  lcb_should_retry(const lcb_settings *settings, const mc_PACKET *pkt, lcb_error_t err)
22
22
  {
23
- unsigned policy;
24
- unsigned mode;
23
+ lcb_RETRYCMDOPTS policy;
24
+ lcb_RETRYMODEOPTS mode;
25
25
  protocol_binary_request_header hdr;
26
26
 
27
27
  mcreq_read_hdr(pkt, &hdr);
@@ -70,6 +70,7 @@ lcb_should_retry(const lcb_settings *settings, const mc_PACKET *pkt, lcb_error_t
70
70
 
71
71
  /* get is a safe operation which may be retried */
72
72
  case PROTOCOL_BINARY_CMD_GET:
73
+ case PROTOCOL_BINARY_CMD_GETKQ:
73
74
  case PROTOCOL_BINARY_CMD_SUBDOC_GET:
74
75
  case PROTOCOL_BINARY_CMD_SUBDOC_EXISTS:
75
76
  case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP:
@@ -231,8 +231,8 @@ RetryQueue::flush(bool throttle)
231
231
  * configuration (i.e. the attempt has not been throttled) then
232
232
  * keep the command in there until it has a chance to be scheduled.
233
233
  */
234
- get_instance()->bootstrap(lcb::BS_REFRESH_THROTTLE);
235
- if (get_instance()->confmon->is_refreshing() ||
234
+ lcb_bootstrap_common(get_instance(), LCB_BS_REFRESH_THROTTLE);
235
+ if (lcb_confmon_is_refreshing(get_instance()->confmon) ||
236
236
  settings->retry[LCB_RETRY_ON_MISSINGNODE]) {
237
237
 
238
238
  lcb_list_delete(static_cast<SchedNode*>(op));
@@ -276,8 +276,8 @@ static void op_dtorfn(mc_EPKTDATUM *d) {
276
276
  delete static_cast<RetryOp*>(d);
277
277
  }
278
278
 
279
- RetryOp::RetryOp()
280
- : mc_EPKTDATUM(), start(0), trytime(0), pkt(NULL), origerr(LCB_SUCCESS) {
279
+ RetryOp::RetryOp() {
280
+ memset(this, 0, sizeof *this);
281
281
  mc_EPKTDATUM::dtorfn = op_dtorfn;
282
282
  mc_EPKTDATUM::key = RETRY_PKT_KEY;
283
283
  }
@@ -57,7 +57,6 @@ void lcb_default_settings(lcb_settings *settings)
57
57
  settings->tcp_nodelay = LCB_DEFAULT_TCP_NODELAY;
58
58
  settings->retry_nmv_interval = LCB_DEFAULT_RETRY_NMV_INTERVAL;
59
59
  settings->vb_noguess = LCB_DEFAULT_VB_NOGUESS;
60
- settings->select_bucket = LCB_DEFAULT_SELECT_BUCKET;
61
60
  }
62
61
 
63
62
  LCB_INTERNAL_API
@@ -68,7 +67,6 @@ lcb_settings_new(void)
68
67
  lcb_default_settings(settings);
69
68
  settings->refcount = 1;
70
69
  settings->auth = lcbauth_new();
71
- settings->errmap = lcb_errmap_new();
72
70
  return settings;
73
71
  }
74
72
 
@@ -85,7 +83,6 @@ lcb_settings_unref(lcb_settings *settings)
85
83
  free(settings->client_string);
86
84
 
87
85
  lcbauth_unref(settings->auth);
88
- lcb_errmap_free(settings->errmap);
89
86
 
90
87
  if (settings->ssl_ctx) {
91
88
  lcbio_ssl_free(settings->ssl_ctx);
@@ -84,11 +84,9 @@
84
84
  #define LCB_DEFAULT_RETRY_NMV_INTERVAL LCB_MS2US(100)
85
85
  #define LCB_DEFAULT_VB_NOGUESS 1
86
86
  #define LCB_DEFAULT_TCP_NODELAY 1
87
- #define LCB_DEFAULT_SELECT_BUCKET 0
88
87
 
89
88
  #include "config.h"
90
89
  #include <libcouchbase/couchbase.h>
91
- #include "errmap.h"
92
90
 
93
91
  #ifdef __cplusplus
94
92
  extern "C" {
@@ -150,8 +148,6 @@ typedef struct lcb_settings_st {
150
148
  unsigned ipv6 : 2;
151
149
  unsigned tcp_nodelay : 1;
152
150
  unsigned readj_ts_wait : 1;
153
- unsigned use_errmap : 1;
154
- unsigned select_bucket : 1;
155
151
 
156
152
  short max_redir;
157
153
  unsigned refcount;
@@ -169,7 +165,6 @@ typedef struct lcb_settings_st {
169
165
  void (*dtorcb)(const void *);
170
166
  void *dtorarg;
171
167
  char *client_string;
172
- lcb_pERRMAP errmap;
173
168
  lcb_U32 retry_nmv_interval;
174
169
  } lcb_settings;
175
170
 
@@ -0,0 +1,211 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2014 Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include "simplestring.h"
19
+ #include "assert.h"
20
+
21
+ static void ensure_cstr(lcb_string *str);
22
+
23
+ int lcb_string_init(lcb_string *str)
24
+ {
25
+ str->base = NULL;
26
+ str->nalloc = 0;
27
+ str->nused = 0;
28
+ return 0;
29
+ }
30
+
31
+ void lcb_string_release(lcb_string *str)
32
+ {
33
+ if (str->base == NULL) {
34
+ return;
35
+ }
36
+ free(str->base);
37
+ memset(str, 0, sizeof(*str));
38
+ }
39
+
40
+ void lcb_string_clear(lcb_string *str)
41
+ {
42
+ str->nused = 0;
43
+ if (str->nalloc) {
44
+ ensure_cstr(str);
45
+ }
46
+ }
47
+
48
+ void lcb_string_added(lcb_string *str, lcb_size_t nused)
49
+ {
50
+ str->nused += nused;
51
+ lcb_assert(str->nused <= str->nalloc);
52
+ ensure_cstr(str);
53
+ }
54
+
55
+ int lcb_string_reserve(lcb_string *str, lcb_size_t size)
56
+ {
57
+ lcb_size_t newalloc;
58
+ char *newbuf;
59
+
60
+ /** Set size to one greater, for the terminating NUL */
61
+ size++;
62
+ if (!size) {
63
+ return -1;
64
+ }
65
+
66
+ if (str->nalloc - str->nused >= size) {
67
+ return 0;
68
+ }
69
+
70
+ newalloc = str->nalloc;
71
+ if (!newalloc) {
72
+ newalloc = 1;
73
+ }
74
+
75
+ while (newalloc - str->nused < size) {
76
+ if (newalloc * 2 < newalloc) {
77
+ return -1;
78
+ }
79
+
80
+ newalloc *= 2;
81
+ }
82
+
83
+ newbuf = realloc(str->base, newalloc);
84
+ if (newbuf == NULL) {
85
+ return -1;
86
+ }
87
+
88
+ str->base = newbuf;
89
+ str->nalloc = newalloc;
90
+ return 0;
91
+ }
92
+
93
+ static void ensure_cstr(lcb_string *str)
94
+ {
95
+ str->base[str->nused] = '\0';
96
+ }
97
+
98
+ int lcb_string_append(lcb_string *str, const void *data, lcb_size_t size)
99
+ {
100
+ if (lcb_string_reserve(str, size)) {
101
+ return -1;
102
+ }
103
+
104
+ memcpy(str->base + str->nused, data, size);
105
+ str->nused += size;
106
+ ensure_cstr(str);
107
+ return 0;
108
+ }
109
+
110
+ int lcb_string_appendz(lcb_string *str, const char *s)
111
+ {
112
+ return lcb_string_append(str, s, strlen(s));
113
+ }
114
+
115
+ int lcb_string_appendv(lcb_string *str, ...)
116
+ {
117
+ va_list ap;
118
+ va_start(ap, str);
119
+
120
+ while (1) {
121
+ size_t len;
122
+ int rc;
123
+ const char *ptr;
124
+
125
+ if ((ptr = va_arg(ap, const char *)) == NULL) {
126
+ return 0;
127
+ }
128
+
129
+ len = va_arg(ap, size_t);
130
+ if (len == (size_t)-1) {
131
+ len = strlen(ptr);
132
+ }
133
+
134
+ rc = lcb_string_append(str, ptr, len);
135
+ if (rc != 0) {
136
+ return -1;
137
+ }
138
+ }
139
+ return 0;
140
+ }
141
+
142
+ int lcb_string_rbappend(lcb_string *str, ringbuffer_t *rb, int rbadvance)
143
+ {
144
+ lcb_size_t expected, nw;
145
+ expected = rb->nbytes;
146
+ if (!expected) {
147
+ return 0;
148
+ }
149
+
150
+ if (lcb_string_reserve(str, expected)) {
151
+ return -1;
152
+ }
153
+
154
+ nw = ringbuffer_peek(rb, lcb_string_tail(str), expected);
155
+ if (nw != expected) {
156
+ return -1;
157
+ }
158
+
159
+ if (rbadvance) {
160
+ ringbuffer_consumed(rb, nw);
161
+ }
162
+
163
+ lcb_string_added(str, nw);
164
+ return 0;
165
+ }
166
+
167
+ void lcb_string_erase_end(lcb_string *str, lcb_size_t to_remove)
168
+ {
169
+ lcb_assert(to_remove <= str->nused);
170
+ str->nused -= to_remove;
171
+ ensure_cstr(str);
172
+ }
173
+
174
+ void lcb_string_erase_beginning(lcb_string *str, lcb_size_t to_remove)
175
+ {
176
+ lcb_assert(to_remove <= str->nused);
177
+ if (!to_remove) {
178
+ str->nused = 0;
179
+ return;
180
+ }
181
+
182
+ memmove(str->base, str->base + to_remove, str->nused - to_remove);
183
+ str->nused -= to_remove;
184
+ ensure_cstr(str);
185
+ }
186
+
187
+ int lcb_string_insert(lcb_string *str, size_t at, const char *src, size_t nsrc)
188
+ {
189
+ if (!nsrc) {
190
+ return 0;
191
+ }
192
+ if (at == str->nused) {
193
+ return lcb_string_append(str, src, nsrc);
194
+ }
195
+
196
+ if (lcb_string_reserve(str, nsrc) != 0) {
197
+ return -1;
198
+ }
199
+ memmove(str->base + at + nsrc, str->base + at, str->nused - at);
200
+ memcpy(str->base + at, src, nsrc);
201
+ str->nused += nsrc;
202
+ ensure_cstr(str);
203
+ return 0;
204
+ }
205
+
206
+ void lcb_string_transfer(lcb_string *from, lcb_string *to)
207
+ {
208
+ lcb_assert(to->base == NULL);
209
+ *to = *from;
210
+ memset(from, 0, sizeof(*from));
211
+ }