libcouchbase 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/ext/libcouchbase/RELEASE_NOTES.markdown +15 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/source_files.cmake +1 -1
- data/ext/libcouchbase/src/{handler.c → handler.cc} +122 -109
- data/ext/libcouchbase/src/instance.cc +1 -1
- data/ext/libcouchbase/src/trace.h +8 -3
- data/lib/libcouchbase/bucket.rb +3 -3
- data/lib/libcouchbase/results_fiber.rb +13 -1
- data/lib/libcouchbase/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e77f4344c80a4dcb25a8b4641eb1f451871999f3
|
4
|
+
data.tar.gz: ad1dfe2a7276dbe6eaf72466203fb44f9989461a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77c92e787e39f9704148c3fce013fe11c52c3a0a6329b22c00f76bfbb47425fb389e3ffbda01b8f2fe2709dfdaa2d064afe2adf56eed3421ad3b044fcff8058d
|
7
|
+
data.tar.gz: fb143e552a235d9aa96412636fe197644c10a81b39780ed9a52cad8729c6f400ce659050bbf41340cd0383e75f91e98d3ad3c91ee7c666afd3fe84f3dcd1685d
|
@@ -1,5 +1,20 @@
|
|
1
1
|
# Release Notes
|
2
2
|
|
3
|
+
## 2.6.4 (November 28 2016)
|
4
|
+
|
5
|
+
* Fix bug in pillowfight where large value sizes would cause a segfault.
|
6
|
+
* Issues: [CCBC-727](https://issues.couchbase.com/browse/CCBC-727)
|
7
|
+
|
8
|
+
* Allow 64 bit values with `cbc-incr` and `cbc-decr`.
|
9
|
+
* Issues: [CCBC-716](https://issues.couchbase.com/browse/CCBC-716)
|
10
|
+
|
11
|
+
* Fix encoding in `lcb_n1p_setconsistent_token`. This function would encode
|
12
|
+
it as `scan_vector` but it should be `scan_vectors`.
|
13
|
+
|
14
|
+
* Refactor negotiation internals to use C++.
|
15
|
+
This is part of an internal refactoring to move our internals over to C++.
|
16
|
+
This will make the code more manageable and extendable in the future.
|
17
|
+
|
3
18
|
## 2.6.3 (September 27 2016)
|
4
19
|
|
5
20
|
* Fix memory corruption for some JSON APIs when no rows are returned.
|
@@ -42,13 +42,13 @@ ENDIF()
|
|
42
42
|
|
43
43
|
IF (NOT LCB_VERSION)
|
44
44
|
SET(LCB_NOGITVERSION ON)
|
45
|
-
SET(LCB_VERSION "2.6.
|
45
|
+
SET(LCB_VERSION "2.6.4")
|
46
46
|
ENDIF()
|
47
47
|
IF (NOT LCB_VERSION_CHANGESET)
|
48
48
|
SET(LCB_VERSION_CHANGESET "0xdeadbeef")
|
49
49
|
ENDIF()
|
50
50
|
IF (NOT LCB_VERSION_HEX)
|
51
|
-
SET(LCB_VERSION_HEX
|
51
|
+
SET(LCB_VERSION_HEX 0x020604)
|
52
52
|
ENDIF()
|
53
53
|
|
54
54
|
# Now parse the version string
|
@@ -63,7 +63,7 @@ IF(APPLE)
|
|
63
63
|
ELSE()
|
64
64
|
SET(LCB_SONAME_MAJOR "2")
|
65
65
|
ENDIF()
|
66
|
-
SET(LCB_SONAME_FULL "${LCB_SONAME_MAJOR}.0.
|
66
|
+
SET(LCB_SONAME_FULL "${LCB_SONAME_MAJOR}.0.39")
|
67
67
|
|
68
68
|
MESSAGE(STATUS
|
69
69
|
"libcouchbase ${LCB_VERSION_MAJOR},${LCB_VERSION_MINOR},${LCB_VERSION_PATCH}")
|
@@ -43,7 +43,6 @@ SET(LCB_CORE_SRC
|
|
43
43
|
src/bootstrap.c
|
44
44
|
src/callbacks.c
|
45
45
|
src/dump.c
|
46
|
-
src/handler.c
|
47
46
|
src/getconfig.c
|
48
47
|
src/legacy.c
|
49
48
|
# src/mcserver/negotiate.c
|
@@ -61,6 +60,7 @@ SET(LCB_CORE_CXXSRC
|
|
61
60
|
src/auth.cc
|
62
61
|
src/connspec.cc
|
63
62
|
src/nodeinfo.cc
|
63
|
+
src/handler.cc
|
64
64
|
src/hostlist.cc
|
65
65
|
src/http/http.cc
|
66
66
|
src/http/http_io.cc
|
@@ -21,20 +21,23 @@
|
|
21
21
|
#include "mc/compress.h"
|
22
22
|
#include "trace.h"
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
template <typename T>
|
25
|
+
class ResponsePack {
|
26
|
+
public:
|
27
|
+
T resp;
|
28
|
+
lcb_MUTATION_TOKEN mt;
|
29
|
+
|
30
|
+
static const lcb_MUTATION_TOKEN*
|
31
|
+
get_mt(const lcb_RESPBASE *rb) {
|
32
|
+
const ResponsePack *rp = reinterpret_cast<const ResponsePack*>(rb);
|
33
|
+
return &rp->mt;
|
34
|
+
}
|
35
|
+
};
|
31
36
|
|
32
37
|
LIBCOUCHBASE_API
|
33
38
|
lcb_error_t
|
34
39
|
lcb_errmap_default(lcb_t instance, lcb_uint16_t in)
|
35
40
|
{
|
36
|
-
(void)instance;
|
37
|
-
|
38
41
|
switch (in) {
|
39
42
|
case PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET:
|
40
43
|
return LCB_ETIMEDOUT;
|
@@ -47,7 +50,11 @@ lcb_errmap_default(lcb_t instance, lcb_uint16_t in)
|
|
47
50
|
|
48
51
|
case PROTOCOL_BINARY_RESPONSE_EINTERNAL:
|
49
52
|
default:
|
50
|
-
|
53
|
+
if (instance) {
|
54
|
+
lcb_log(instance->settings, "handler", LCB_LOG_ERROR, __FILE__, __LINE__, "Got unhandled memcached error 0x%X", in);
|
55
|
+
} else {
|
56
|
+
fprintf(stderr, "COUCHBASE: Unhandled memcached status=0x%x\n", in);
|
57
|
+
}
|
51
58
|
return LCB_UNKNOWN_MEMCACHED_ERROR;
|
52
59
|
}
|
53
60
|
}
|
@@ -55,7 +62,6 @@ lcb_errmap_default(lcb_t instance, lcb_uint16_t in)
|
|
55
62
|
static lcb_error_t
|
56
63
|
map_error(lcb_t instance, int in)
|
57
64
|
{
|
58
|
-
(void)instance;
|
59
65
|
switch (in) {
|
60
66
|
case PROTOCOL_BINARY_RESPONSE_SUCCESS:
|
61
67
|
return LCB_SUCCESS;
|
@@ -153,24 +159,26 @@ find_callback(lcb_t instance, lcb_CALLBACKTYPE type)
|
|
153
159
|
* satisfied.
|
154
160
|
*/
|
155
161
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
} else {
|
163
|
-
|
164
|
-
}
|
165
|
-
|
162
|
+
template <typename T>
|
163
|
+
void make_error(lcb_t instance, T* resp,
|
164
|
+
const packet_info *response, lcb_error_t imm) {
|
165
|
+
if (imm) {
|
166
|
+
resp->rc = imm;
|
167
|
+
resp->rflags |= LCB_RESP_F_CLIENTGEN;
|
168
|
+
} else if (PACKET_STATUS(response) == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
|
169
|
+
resp->rc = LCB_SUCCESS;
|
170
|
+
} else {
|
171
|
+
resp->rc = map_error(instance, PACKET_STATUS(response));
|
172
|
+
}
|
173
|
+
}
|
166
174
|
|
167
|
-
|
168
|
-
|
169
|
-
lcb_error_t immerr,
|
175
|
+
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)
|
170
178
|
{
|
171
|
-
|
179
|
+
make_error(instance, resp, mc_resp, immerr);
|
172
180
|
resp->cas = PACKET_CAS(mc_resp);
|
173
|
-
resp->cookie = (
|
181
|
+
resp->cookie = const_cast<void*>(MCREQ_PKT_COOKIE(req));
|
174
182
|
mcreq_get_key(req, &resp->key, &resp->nkey);
|
175
183
|
}
|
176
184
|
|
@@ -194,11 +202,12 @@ handle_mutation_token(lcb_t instance, const packet_info *mc_resp,
|
|
194
202
|
if (!instance->dcpinfo && LCBT_SETTING(instance, dur_mutation_tokens)) {
|
195
203
|
size_t nvb = LCBT_VBCONFIG(instance)->nvb;
|
196
204
|
if (nvb) {
|
197
|
-
instance->dcpinfo =
|
205
|
+
instance->dcpinfo = new lcb_MUTATION_TOKEN[nvb];
|
206
|
+
memset(instance->dcpinfo, 0, sizeof(*instance->dcpinfo) * nvb);
|
198
207
|
}
|
199
208
|
}
|
200
209
|
|
201
|
-
sbuf = PACKET_BODY(mc_resp);
|
210
|
+
sbuf = reinterpret_cast<const char *>(PACKET_BODY(mc_resp));
|
202
211
|
vbid = mcreq_get_vbucket(req);
|
203
212
|
stok->vbid_ = vbid;
|
204
213
|
memcpy(&stok->uuid_, sbuf, 8);
|
@@ -212,26 +221,30 @@ handle_mutation_token(lcb_t instance, const packet_info *mc_resp,
|
|
212
221
|
}
|
213
222
|
}
|
214
223
|
|
215
|
-
|
216
|
-
|
217
|
-
}
|
218
|
-
|
224
|
+
static lcb_t get_instance(mc_PIPELINE *pipeline) {
|
225
|
+
return reinterpret_cast<lcb_t>(pipeline->parent->cqdata);
|
226
|
+
}
|
219
227
|
|
220
|
-
|
221
|
-
|
222
|
-
lcb_t instance,
|
228
|
+
template <typename T>
|
229
|
+
void invoke_callback(const mc_PACKET *pkt,
|
230
|
+
lcb_t instance, T* resp, lcb_CALLBACKTYPE cbtype)
|
223
231
|
{
|
224
232
|
if (!(pkt->flags & MCREQ_F_INVOKED)) {
|
225
|
-
resp->cookie = (
|
233
|
+
resp->cookie = const_cast<void*>(MCREQ_PKT_COOKIE(pkt));
|
234
|
+
const lcb_RESPBASE *base = reinterpret_cast<const lcb_RESPBASE*>(resp);
|
226
235
|
if ((pkt->flags & MCREQ_F_PRIVCALLBACK) == 0) {
|
227
|
-
find_callback(instance, cbtype)(instance, cbtype,
|
236
|
+
find_callback(instance, cbtype)(instance, cbtype, base);
|
228
237
|
} else {
|
229
|
-
(*(lcb_RESPCALLBACK*)resp->cookie)(instance, cbtype,
|
238
|
+
(*(lcb_RESPCALLBACK*)resp->cookie)(instance, cbtype, base);
|
230
239
|
}
|
231
240
|
}
|
232
241
|
}
|
233
|
-
|
234
|
-
|
242
|
+
|
243
|
+
template <typename T>
|
244
|
+
void invoke_callback(const mc_PACKET *pkt, mc_PIPELINE *pipeline, T *resp,
|
245
|
+
lcb_CALLBACKTYPE cbtype)
|
246
|
+
{
|
247
|
+
invoke_callback(pkt, get_instance(pipeline), cbtype, resp);
|
235
248
|
}
|
236
249
|
|
237
250
|
/**
|
@@ -276,27 +289,27 @@ static void
|
|
276
289
|
H_get(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
277
290
|
lcb_error_t immerr)
|
278
291
|
{
|
279
|
-
lcb_t o;
|
280
292
|
lcb_RESPGET resp = { 0 };
|
281
|
-
void *freeptr = NULL;
|
282
293
|
|
283
|
-
o = pipeline
|
284
|
-
|
294
|
+
lcb_t o = get_instance(pipeline);
|
295
|
+
init_resp(o, response, request, immerr, &resp);
|
285
296
|
resp.rflags |= LCB_RESP_F_FINAL;
|
286
297
|
|
287
298
|
if (resp.rc == LCB_SUCCESS) {
|
288
|
-
const
|
289
|
-
|
299
|
+
const protocol_binary_response_get *get =
|
300
|
+
reinterpret_cast<const protocol_binary_response_get*>(
|
301
|
+
PACKET_EPHEMERAL_START(response));
|
290
302
|
resp.datatype = PACKET_DATATYPE(response);
|
291
|
-
resp.itmflags = ntohl(
|
303
|
+
resp.itmflags = ntohl(get->message.body.flags);
|
292
304
|
resp.value = PACKET_VALUE(response);
|
293
305
|
resp.nvalue = PACKET_NVALUE(response);
|
294
306
|
resp.bufh = response->bufh;
|
295
307
|
}
|
296
308
|
|
309
|
+
void *freeptr = NULL;
|
297
310
|
maybe_decompress(o, response, &resp, &freeptr);
|
298
311
|
TRACE_GET_END(response, &resp);
|
299
|
-
|
312
|
+
invoke_callback(request, o, &resp, LCB_CALLBACK_GET);
|
300
313
|
free(freeptr);
|
301
314
|
}
|
302
315
|
|
@@ -305,14 +318,16 @@ H_getreplica(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
|
305
318
|
lcb_error_t immerr)
|
306
319
|
{
|
307
320
|
lcb_RESPGET resp = { 0 };
|
308
|
-
lcb_t instance = pipeline
|
321
|
+
lcb_t instance = get_instance(pipeline);
|
309
322
|
void *freeptr = NULL;
|
310
323
|
mc_REQDATAEX *rd = request->u_rdata.exdata;
|
311
324
|
|
312
|
-
|
325
|
+
init_resp(instance, response, request, immerr, &resp);
|
313
326
|
|
314
327
|
if (resp.rc == LCB_SUCCESS) {
|
315
|
-
const protocol_binary_response_get *get =
|
328
|
+
const protocol_binary_response_get *get =
|
329
|
+
reinterpret_cast<const protocol_binary_response_get*>(
|
330
|
+
PACKET_EPHEMERAL_START(response));
|
316
331
|
resp.itmflags = ntohl(get->message.body.flags);
|
317
332
|
resp.datatype = PACKET_DATATYPE(response);
|
318
333
|
resp.value = PACKET_VALUE(response);
|
@@ -329,11 +344,10 @@ static void
|
|
329
344
|
H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
330
345
|
lcb_error_t immerr)
|
331
346
|
{
|
332
|
-
lcb_t o;
|
333
|
-
|
334
|
-
|
335
|
-
o
|
336
|
-
init_resp3(o, response, request, immerr, (lcb_RESPBASE *)&w.resp);
|
347
|
+
lcb_t o = get_instance(pipeline);
|
348
|
+
ResponsePack<lcb_RESPSUBDOC> w = {{ 0 }};
|
349
|
+
lcb_CALLBACKTYPE cbtype;
|
350
|
+
init_resp(o, response, request, immerr, &w.resp);
|
337
351
|
w.resp.rflags |= LCB_RESP_F_FINAL;
|
338
352
|
|
339
353
|
/* For mutations, add the mutation token */
|
@@ -366,15 +380,15 @@ H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
|
366
380
|
w.resp.rc = LCB_SUBDOC_MULTI_FAILURE;
|
367
381
|
}
|
368
382
|
}
|
369
|
-
|
383
|
+
invoke_callback(request, o, &w.resp, cbtype);
|
370
384
|
}
|
371
385
|
|
372
386
|
static int
|
373
387
|
sdlookup_next(const packet_info *response, lcb_SDENTRY *ent, size_t *iter)
|
374
388
|
{
|
375
389
|
const char *buf;
|
376
|
-
|
377
|
-
|
390
|
+
uint16_t rc;
|
391
|
+
uint32_t vlen;
|
378
392
|
|
379
393
|
if (*iter == PACKET_NVALUE(response)) {
|
380
394
|
return 0;
|
@@ -407,8 +421,8 @@ static int
|
|
407
421
|
sdmutate_next(const packet_info *response, lcb_SDENTRY *ent, size_t *iter)
|
408
422
|
{
|
409
423
|
const char *buf, *buf_end;
|
410
|
-
|
411
|
-
|
424
|
+
uint16_t rc;
|
425
|
+
uint32_t vlen;
|
412
426
|
|
413
427
|
if (*iter == PACKET_NVALUE(response)) {
|
414
428
|
return 0;
|
@@ -492,28 +506,28 @@ static void
|
|
492
506
|
H_delete(mc_PIPELINE *pipeline, mc_PACKET *packet, packet_info *response,
|
493
507
|
lcb_error_t immerr)
|
494
508
|
{
|
495
|
-
lcb_t root = pipeline
|
496
|
-
|
509
|
+
lcb_t root = get_instance(pipeline);
|
510
|
+
ResponsePack<lcb_RESPREMOVE> w = { { 0 } };
|
497
511
|
w.resp.rflags |= LCB_RESP_F_EXTDATA | LCB_RESP_F_FINAL;
|
498
|
-
|
512
|
+
init_resp(root, response, packet, immerr, &w.resp);
|
499
513
|
handle_mutation_token(root, response, packet, &w.mt);
|
500
514
|
TRACE_REMOVE_END(response, &w.resp);
|
501
|
-
|
515
|
+
invoke_callback(packet, root, &w.resp, LCB_CALLBACK_REMOVE);
|
502
516
|
}
|
503
517
|
|
504
518
|
static void
|
505
519
|
H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
506
520
|
lcb_error_t immerr)
|
507
521
|
{
|
508
|
-
lcb_t root = pipeline
|
522
|
+
lcb_t root = get_instance(pipeline);
|
509
523
|
uint32_t ttp;
|
510
524
|
uint32_t ttr;
|
511
|
-
|
525
|
+
size_t pos;
|
512
526
|
lcbvb_CONFIG* config;
|
513
527
|
const char *end, *ptr;
|
514
528
|
mc_REQDATAEX *rd = request->u_rdata.exdata;
|
515
529
|
lcb_RESPOBSERVE resp = { 0 };
|
516
|
-
|
530
|
+
make_error(root, &resp, response, immerr);
|
517
531
|
|
518
532
|
if (resp.rc != LCB_SUCCESS) {
|
519
533
|
if (! (request->flags & MCREQ_F_INVOKED)) {
|
@@ -531,14 +545,14 @@ H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
|
531
545
|
ttr = ntohl(ttr);
|
532
546
|
|
533
547
|
/** Actual payload sequence of (vb, nkey, key). Repeats multiple times */
|
534
|
-
ptr = response->payload;
|
548
|
+
ptr = reinterpret_cast<const char *>(response->payload);
|
535
549
|
end = (char *)ptr + PACKET_NBODY(response);
|
536
550
|
config = pipeline->parent->config;
|
537
551
|
|
538
552
|
for (pos = 0; ptr < end; pos++) {
|
539
|
-
|
540
|
-
|
541
|
-
|
553
|
+
uint64_t cas;
|
554
|
+
uint8_t obs;
|
555
|
+
uint16_t nkey, vb;
|
542
556
|
const char *key;
|
543
557
|
|
544
558
|
memcpy(&vb, ptr, sizeof(vb));
|
@@ -573,15 +587,15 @@ static void
|
|
573
587
|
H_observe_seqno(mc_PIPELINE *pipeline, mc_PACKET *request,
|
574
588
|
packet_info *response, lcb_error_t immerr)
|
575
589
|
{
|
576
|
-
lcb_t root = pipeline
|
590
|
+
lcb_t root = get_instance(pipeline);
|
577
591
|
lcb_RESPOBSEQNO resp = { 0 };
|
578
|
-
|
592
|
+
init_resp(root, response, request, immerr, &resp);
|
579
593
|
|
580
594
|
resp.server_index = pipeline->index;
|
581
595
|
|
582
596
|
if (resp.rc == LCB_SUCCESS) {
|
583
|
-
const
|
584
|
-
|
597
|
+
const uint8_t *data = reinterpret_cast<const uint8_t*>(PACKET_BODY(response));
|
598
|
+
bool is_failover = *data != 0;
|
585
599
|
|
586
600
|
data++;
|
587
601
|
#define COPY_ADV(dstfld, n, conv_fn) \
|
@@ -602,17 +616,17 @@ H_observe_seqno(mc_PIPELINE *pipeline, mc_PACKET *request,
|
|
602
616
|
/* Get the server for this command. Note that since this is a successful
|
603
617
|
* operation, the server is never a dummy */
|
604
618
|
}
|
605
|
-
|
619
|
+
invoke_callback(request, root, &resp, LCB_CALLBACK_OBSEQNO);
|
606
620
|
}
|
607
621
|
|
608
622
|
static void
|
609
623
|
H_store(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
610
624
|
lcb_error_t immerr)
|
611
625
|
{
|
612
|
-
lcb_t root = pipeline
|
613
|
-
|
614
|
-
|
615
|
-
|
626
|
+
lcb_t root = get_instance(pipeline);
|
627
|
+
ResponsePack<lcb_RESPSTORE> w = { { 0 } };
|
628
|
+
uint8_t opcode;
|
629
|
+
init_resp(root, response, request, immerr, &w.resp);
|
616
630
|
if (!immerr) {
|
617
631
|
opcode = PACKET_OPCODE(response);
|
618
632
|
} else {
|
@@ -637,7 +651,7 @@ H_store(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
|
637
651
|
if (request->flags & MCREQ_F_REQEXT) {
|
638
652
|
request->u_rdata.exdata->procs->handler(pipeline, request, immerr, &w.resp);
|
639
653
|
} else {
|
640
|
-
|
654
|
+
invoke_callback(request, root, &w.resp, LCB_CALLBACK_STORE);
|
641
655
|
}
|
642
656
|
}
|
643
657
|
|
@@ -645,9 +659,9 @@ static void
|
|
645
659
|
H_arithmetic(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
646
660
|
lcb_error_t immerr)
|
647
661
|
{
|
648
|
-
lcb_t root = pipeline
|
649
|
-
|
650
|
-
|
662
|
+
lcb_t root = get_instance(pipeline);
|
663
|
+
ResponsePack<lcb_RESPCOUNTER> w = { { 0 } };
|
664
|
+
init_resp(root, response, request, immerr, &w.resp);
|
651
665
|
|
652
666
|
if (w.resp.rc == LCB_SUCCESS) {
|
653
667
|
memcpy(&w.resp.value, PACKET_VALUE(response), sizeof(w.resp.value));
|
@@ -658,18 +672,18 @@ H_arithmetic(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
|
658
672
|
w.resp.rflags |= LCB_RESP_F_FINAL;
|
659
673
|
w.resp.cas = PACKET_CAS(response);
|
660
674
|
TRACE_ARITHMETIC_END(response, &w.resp);
|
661
|
-
|
675
|
+
invoke_callback(request, root, &w.resp, LCB_CALLBACK_COUNTER);
|
662
676
|
}
|
663
677
|
|
664
678
|
static void
|
665
679
|
H_stats(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
666
680
|
lcb_error_t immerr)
|
667
681
|
{
|
668
|
-
lcb_t root = pipeline
|
682
|
+
lcb_t root = get_instance(pipeline);
|
669
683
|
lcb_RESPSTATS resp = { 0 };
|
670
684
|
mc_REQDATAEX *exdata;
|
671
685
|
|
672
|
-
|
686
|
+
make_error(root, &resp, response, immerr);
|
673
687
|
resp.version = 0;
|
674
688
|
|
675
689
|
exdata = request->u_rdata.exdata;
|
@@ -694,10 +708,10 @@ static void
|
|
694
708
|
H_verbosity(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
695
709
|
lcb_error_t immerr)
|
696
710
|
{
|
697
|
-
lcb_t root = pipeline
|
711
|
+
lcb_t root = get_instance(pipeline);
|
698
712
|
lcb_RESPBASE dummy = { 0 };
|
699
713
|
mc_REQDATAEX *exdata = request->u_rdata.exdata;
|
700
|
-
|
714
|
+
make_error(root, &dummy, response, immerr);
|
701
715
|
|
702
716
|
exdata->procs->handler(pipeline, request, dummy.rc, NULL);
|
703
717
|
}
|
@@ -706,14 +720,14 @@ static void
|
|
706
720
|
H_version(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
707
721
|
lcb_error_t immerr)
|
708
722
|
{
|
709
|
-
lcb_t root = pipeline
|
723
|
+
lcb_t root = get_instance(pipeline);
|
710
724
|
lcb_RESPMCVERSION resp = { 0 };
|
711
725
|
mc_REQDATAEX *exdata = request->u_rdata.exdata;
|
712
726
|
|
713
|
-
|
727
|
+
make_error(root, &resp, response, immerr);
|
714
728
|
|
715
729
|
if (PACKET_NBODY(response)) {
|
716
|
-
resp.mcversion = response->payload;
|
730
|
+
resp.mcversion = reinterpret_cast<const char *>(response->payload);
|
717
731
|
resp.nversion = PACKET_NBODY(response);
|
718
732
|
}
|
719
733
|
|
@@ -725,22 +739,22 @@ static void
|
|
725
739
|
H_touch(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
726
740
|
lcb_error_t immerr)
|
727
741
|
{
|
728
|
-
lcb_t root = pipeline
|
742
|
+
lcb_t root = get_instance(pipeline);
|
729
743
|
lcb_RESPTOUCH resp = { 0 };
|
730
|
-
|
744
|
+
init_resp(root, response, request, immerr, &resp);
|
731
745
|
resp.rflags |= LCB_RESP_F_FINAL;
|
732
746
|
TRACE_TOUCH_END(response, &resp);
|
733
|
-
|
747
|
+
invoke_callback(request, root, &resp, LCB_CALLBACK_TOUCH);
|
734
748
|
}
|
735
749
|
|
736
750
|
static void
|
737
751
|
H_flush(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
738
752
|
lcb_error_t immerr)
|
739
753
|
{
|
740
|
-
lcb_t root = pipeline
|
754
|
+
lcb_t root = get_instance(pipeline);
|
741
755
|
lcb_RESPFLUSH resp = { 0 };
|
742
756
|
mc_REQDATAEX *exdata = request->u_rdata.exdata;
|
743
|
-
|
757
|
+
make_error(root, &resp, response, immerr);
|
744
758
|
exdata->procs->handler(pipeline, request, resp.rc, &resp);
|
745
759
|
}
|
746
760
|
|
@@ -748,12 +762,12 @@ static void
|
|
748
762
|
H_unlock(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
749
763
|
lcb_error_t immerr)
|
750
764
|
{
|
751
|
-
lcb_t root = pipeline
|
765
|
+
lcb_t root = get_instance(pipeline);
|
752
766
|
lcb_RESPUNLOCK resp = { 0 };
|
753
|
-
|
767
|
+
init_resp(root, response, request, immerr, &resp);
|
754
768
|
resp.rflags |= LCB_RESP_F_FINAL;
|
755
769
|
TRACE_UNLOCK_END(response, &resp);
|
756
|
-
|
770
|
+
invoke_callback(request, root, &resp, LCB_CALLBACK_UNLOCK);
|
757
771
|
}
|
758
772
|
|
759
773
|
static void
|
@@ -763,20 +777,19 @@ H_config(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
|
763
777
|
/** We just jump to the normal config handler */
|
764
778
|
lcb_RESPBASE dummy;
|
765
779
|
mc_REQDATAEX *exdata = request->u_rdata.exdata;
|
766
|
-
|
780
|
+
make_error(get_instance(pipeline), &dummy, response, immerr);
|
767
781
|
|
768
782
|
exdata->procs->handler(pipeline, request, dummy.rc, response);
|
769
783
|
}
|
770
784
|
|
771
785
|
static void
|
772
|
-
record_metrics(mc_PIPELINE *pipeline, mc_PACKET *req, packet_info *
|
786
|
+
record_metrics(mc_PIPELINE *pipeline, mc_PACKET *req, packet_info *)
|
773
787
|
{
|
774
|
-
lcb_t instance = pipeline
|
788
|
+
lcb_t instance = get_instance(pipeline);
|
775
789
|
if (instance->kv_timings) {
|
776
790
|
lcb_histogram_record(instance->kv_timings,
|
777
791
|
gethrtime() - MCREQ_PKT_RDATA(req)->start);
|
778
792
|
}
|
779
|
-
(void)res;
|
780
793
|
}
|
781
794
|
|
782
795
|
static void
|
@@ -896,19 +909,19 @@ lcb_resp_get_mutation_token(int cbtype, const lcb_RESPBASE *rb)
|
|
896
909
|
|
897
910
|
switch (cbtype) {
|
898
911
|
case LCB_CALLBACK_STORE:
|
899
|
-
ss =
|
912
|
+
ss = ResponsePack<lcb_RESPSTORE>::get_mt(rb);
|
900
913
|
break;
|
901
914
|
|
902
915
|
case LCB_CALLBACK_COUNTER:
|
903
|
-
ss =
|
916
|
+
ss = ResponsePack<lcb_RESPCOUNTER>::get_mt(rb);
|
904
917
|
break;
|
905
918
|
|
906
919
|
case LCB_CALLBACK_REMOVE:
|
907
|
-
ss =
|
920
|
+
ss = ResponsePack<lcb_RESPREMOVE>::get_mt(rb);
|
908
921
|
break;
|
909
922
|
|
910
923
|
case LCB_CALLBACK_SDMUTATE:
|
911
|
-
ss =
|
924
|
+
ss = ResponsePack<lcb_RESPSUBDOC>::get_mt(rb);
|
912
925
|
break;
|
913
926
|
|
914
927
|
default:
|
@@ -18,9 +18,14 @@
|
|
18
18
|
#ifndef LIBCOUCHBASE_TRACE_H
|
19
19
|
#define LIBCOUCHBASE_TRACE_H 1
|
20
20
|
|
21
|
-
#
|
21
|
+
#if defined(__clang__) || defined(__GNUC__)
|
22
22
|
#pragma GCC diagnostic push
|
23
|
+
|
24
|
+
#ifdef __clang__
|
23
25
|
#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
|
26
|
+
#else
|
27
|
+
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
28
|
+
#endif
|
24
29
|
#endif
|
25
30
|
|
26
31
|
#ifdef HAVE_DTRACE
|
@@ -42,11 +47,11 @@
|
|
42
47
|
(cmd)->key.contig.bytes, (cmd)->key.contig.nbytes)
|
43
48
|
|
44
49
|
#define TRACE_END_COMMON(TGT, mcresp, resp, ...) \
|
45
|
-
TGT(PACKET_OPAQUE(mcresp), 0, PACKET_OPCODE(mcresp), (resp)->rc, (resp)->key, (resp)->nkey, \
|
50
|
+
TGT(PACKET_OPAQUE(mcresp), 0, PACKET_OPCODE(mcresp), (resp)->rc, (const char *)(resp)->key, (resp)->nkey, \
|
46
51
|
## __VA_ARGS__)
|
47
52
|
|
48
53
|
#define TRACE_END_SIMPLE(TGT, mcresp, resp) \
|
49
|
-
TGT(PACKET_OPAQUE(mcresp), 0, PACKET_OPCODE(mcresp), (resp)->rc, (resp)->key, (resp)->nkey)
|
54
|
+
TGT(PACKET_OPAQUE(mcresp), 0, PACKET_OPCODE(mcresp), (resp)->rc, (const char *)(resp)->key, (resp)->nkey)
|
50
55
|
|
51
56
|
#define TRACE_GET_BEGIN(req, cmd) \
|
52
57
|
TRACE(TRACE_BEGIN_COMMON(LIBCOUCHBASE_GET_BEGIN, req, cmd, (cmd)->exptime))
|
data/lib/libcouchbase/bucket.rb
CHANGED
@@ -139,10 +139,10 @@ module Libcouchbase
|
|
139
139
|
end
|
140
140
|
|
141
141
|
result(@reactor.all(*promises).then(proc { |results|
|
142
|
-
if
|
143
|
-
results.collect! { |resp| resp.value if resp }
|
144
|
-
else
|
142
|
+
if extended
|
145
143
|
results.compact!
|
144
|
+
else
|
145
|
+
results.collect! { |resp| resp.value if resp }
|
146
146
|
end
|
147
147
|
|
148
148
|
if assemble_hash
|
@@ -12,6 +12,12 @@ module Libcouchbase
|
|
12
12
|
@results = []
|
13
13
|
@fiber = nil
|
14
14
|
|
15
|
+
# We don't want to resume a fiber that is waiting
|
16
|
+
# in a yield to user code as then the Fiber might
|
17
|
+
# end before we've finished processing and this is
|
18
|
+
# very much not desirable - dead fiber errors
|
19
|
+
@resume_results = true
|
20
|
+
|
15
21
|
# This could be a view or n1ql query
|
16
22
|
@query = query
|
17
23
|
@row_modifier = row_modifier
|
@@ -33,8 +39,10 @@ module Libcouchbase
|
|
33
39
|
begin
|
34
40
|
while not @query_completed do
|
35
41
|
if @results.length > 0
|
42
|
+
@resume_results = false
|
36
43
|
yield @results.shift
|
37
44
|
else
|
45
|
+
@resume_results = true
|
38
46
|
resume
|
39
47
|
end
|
40
48
|
end
|
@@ -42,6 +50,7 @@ module Libcouchbase
|
|
42
50
|
# cancel is executed on break or error
|
43
51
|
cancel unless @query_completed
|
44
52
|
@fiber = nil
|
53
|
+
@resume_results = true
|
45
54
|
end
|
46
55
|
end
|
47
56
|
self
|
@@ -69,9 +78,11 @@ module Libcouchbase
|
|
69
78
|
begin
|
70
79
|
while not @query_completed do
|
71
80
|
if index < @results.length
|
81
|
+
@resume_results = false
|
72
82
|
yield @results[index]
|
73
83
|
index += 1
|
74
84
|
else
|
85
|
+
@resume_results = true
|
75
86
|
resume
|
76
87
|
end
|
77
88
|
end
|
@@ -79,6 +90,7 @@ module Libcouchbase
|
|
79
90
|
# cancel is executed on break or error
|
80
91
|
cancel unless @query_completed
|
81
92
|
@fiber = nil
|
93
|
+
@resume_results = true
|
82
94
|
end
|
83
95
|
end
|
84
96
|
self
|
@@ -202,7 +214,7 @@ module Libcouchbase
|
|
202
214
|
end
|
203
215
|
|
204
216
|
# Resume processing
|
205
|
-
@fiber.resume if @fiber && (!@cancelled || final)
|
217
|
+
@fiber.resume if @fiber && @resume_results && (!@cancelled || final)
|
206
218
|
end
|
207
219
|
end
|
208
220
|
|
data/lib/libcouchbase/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libcouchbase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen von Takach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -406,7 +406,7 @@ files:
|
|
406
406
|
- ext/libcouchbase/src/dump.c
|
407
407
|
- ext/libcouchbase/src/getconfig.c
|
408
408
|
- ext/libcouchbase/src/gethrtime.c
|
409
|
-
- ext/libcouchbase/src/handler.
|
409
|
+
- ext/libcouchbase/src/handler.cc
|
410
410
|
- ext/libcouchbase/src/hashtable.c
|
411
411
|
- ext/libcouchbase/src/hdr_timings.c
|
412
412
|
- ext/libcouchbase/src/hostlist.cc
|