libcouchbase 1.2.8 → 1.3.0
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/.travis.yml +4 -4
- data/README.md +16 -8
- data/ext/libcouchbase/CMakeLists.txt +34 -32
- data/ext/libcouchbase/RELEASE_NOTES.markdown +277 -6
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +14 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +2 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +2 -1
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +8 -1
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/config-cmake.h.in +14 -0
- data/ext/libcouchbase/cmake/configure +8 -26
- data/ext/libcouchbase/cmake/defs.mk.in +2 -2
- data/ext/libcouchbase/cmake/libcouchbase.stp.in +829 -0
- data/ext/libcouchbase/cmake/source_files.cmake +11 -2
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +18 -2
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +44 -2
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +285 -73
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +4 -0
- data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.c +500 -0
- data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.h +99 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +1 -1
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +14 -1
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +2 -3
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +4 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +7 -5
- data/ext/libcouchbase/contrib/snappy/snappy.cc +7 -2
- data/ext/libcouchbase/example/crypto/.gitignore +2 -0
- data/ext/libcouchbase/example/crypto/Makefile +13 -0
- data/ext/libcouchbase/example/crypto/common_provider.c +24 -0
- data/ext/libcouchbase/example/crypto/common_provider.h +31 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +139 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +147 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +281 -0
- data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.h +29 -0
- data/ext/libcouchbase/example/tracing/.gitignore +2 -0
- data/ext/libcouchbase/example/tracing/Makefile +8 -0
- data/ext/libcouchbase/example/tracing/cJSON.c +1 -0
- data/ext/libcouchbase/example/tracing/cJSON.h +1 -0
- data/ext/libcouchbase/example/tracing/tracing.c +439 -0
- data/ext/libcouchbase/example/tracing/views.c +444 -0
- data/ext/libcouchbase/include/libcouchbase/auth.h +56 -4
- data/ext/libcouchbase/include/libcouchbase/cbft.h +8 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +55 -1
- data/ext/libcouchbase/include/libcouchbase/cntl.h +101 -1
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +6 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +109 -6
- data/ext/libcouchbase/include/libcouchbase/crypto.h +140 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +38 -2
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +6 -1
- data/ext/libcouchbase/include/libcouchbase/metrics.h +79 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +9 -0
- data/ext/libcouchbase/include/libcouchbase/tracing.h +319 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +1 -1
- data/ext/libcouchbase/include/libcouchbase/views.h +8 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +40 -10
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +6 -14
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +3 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +1 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +4 -1
- data/ext/libcouchbase/src/auth-priv.h +36 -4
- data/ext/libcouchbase/src/auth.cc +66 -27
- data/ext/libcouchbase/src/bootstrap.cc +1 -1
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +12 -7
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +26 -17
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +1 -1
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +4 -2
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +6 -3
- data/ext/libcouchbase/src/cbft.cc +48 -0
- data/ext/libcouchbase/src/cntl.cc +138 -2
- data/ext/libcouchbase/src/config_static.h +17 -0
- data/ext/libcouchbase/src/connspec.cc +54 -6
- data/ext/libcouchbase/src/connspec.h +9 -1
- data/ext/libcouchbase/src/crypto.cc +386 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +23 -6
- data/ext/libcouchbase/src/dump.cc +4 -0
- data/ext/libcouchbase/src/getconfig.cc +1 -2
- data/ext/libcouchbase/src/handler.cc +65 -27
- data/ext/libcouchbase/src/hostlist.cc +35 -7
- data/ext/libcouchbase/src/hostlist.h +7 -0
- data/ext/libcouchbase/src/http/http-priv.h +2 -0
- data/ext/libcouchbase/src/http/http.cc +77 -37
- data/ext/libcouchbase/src/http/http_io.cc +19 -2
- data/ext/libcouchbase/src/instance.cc +90 -17
- data/ext/libcouchbase/src/internal.h +5 -0
- data/ext/libcouchbase/src/lcbio/connect.cc +39 -4
- data/ext/libcouchbase/src/lcbio/connect.h +27 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +49 -23
- data/ext/libcouchbase/src/lcbio/ioutils.cc +30 -3
- data/ext/libcouchbase/src/lcbio/ioutils.h +2 -0
- data/ext/libcouchbase/src/lcbio/manager.cc +44 -8
- data/ext/libcouchbase/src/lcbio/manager.h +2 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +1 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +3 -5
- data/ext/libcouchbase/src/logging.c +1 -1
- data/ext/libcouchbase/src/logging.h +2 -0
- data/ext/libcouchbase/src/mc/compress.cc +164 -0
- data/ext/libcouchbase/src/mc/compress.h +7 -12
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +5 -1
- data/ext/libcouchbase/src/mc/mcreq.c +11 -1
- data/ext/libcouchbase/src/mc/mcreq.h +35 -4
- data/ext/libcouchbase/src/mcserver/mcserver.cc +30 -7
- data/ext/libcouchbase/src/mcserver/mcserver.h +7 -0
- data/ext/libcouchbase/src/mcserver/negotiate.cc +103 -57
- data/ext/libcouchbase/src/mcserver/negotiate.h +2 -2
- data/ext/libcouchbase/src/mctx-helper.h +11 -0
- data/ext/libcouchbase/src/metrics.cc +132 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
- data/ext/libcouchbase/src/n1ql/n1ql.cc +66 -0
- data/ext/libcouchbase/src/newconfig.cc +9 -2
- data/ext/libcouchbase/src/operations/counter.cc +2 -1
- data/ext/libcouchbase/src/operations/durability-cas.cc +11 -0
- data/ext/libcouchbase/src/operations/durability-seqno.cc +3 -0
- data/ext/libcouchbase/src/operations/durability.cc +24 -2
- data/ext/libcouchbase/src/operations/durability_internal.h +19 -0
- data/ext/libcouchbase/src/operations/get.cc +4 -2
- data/ext/libcouchbase/src/operations/observe-seqno.cc +1 -0
- data/ext/libcouchbase/src/operations/observe.cc +113 -62
- data/ext/libcouchbase/src/operations/ping.cc +246 -67
- data/ext/libcouchbase/src/operations/remove.cc +2 -1
- data/ext/libcouchbase/src/operations/store.cc +17 -14
- data/ext/libcouchbase/src/operations/touch.cc +3 -0
- data/ext/libcouchbase/src/packetutils.h +68 -4
- data/ext/libcouchbase/src/probes.d +132 -161
- data/ext/libcouchbase/src/rdb/bigalloc.c +1 -1
- data/ext/libcouchbase/src/retryq.cc +6 -2
- data/ext/libcouchbase/src/rnd.cc +68 -0
- data/ext/libcouchbase/src/rnd.h +39 -0
- data/ext/libcouchbase/src/settings.c +27 -0
- data/ext/libcouchbase/src/settings.h +67 -3
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +0 -12
- data/ext/libcouchbase/src/ssl/ssl_common.c +23 -4
- data/ext/libcouchbase/src/strcodecs/base64.c +141 -16
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +16 -1
- data/ext/libcouchbase/src/trace.h +68 -61
- data/ext/libcouchbase/src/tracing/span.cc +289 -0
- data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +171 -0
- data/ext/libcouchbase/src/tracing/tracer.cc +53 -0
- data/ext/libcouchbase/src/tracing/tracing-internal.h +213 -0
- data/ext/libcouchbase/src/utilities.c +5 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -2
- data/ext/libcouchbase/src/vbucket/vbucket.c +50 -18
- data/ext/libcouchbase/src/views/docreq.cc +26 -1
- data/ext/libcouchbase/src/views/docreq.h +17 -0
- data/ext/libcouchbase/src/views/viewreq.cc +64 -1
- data/ext/libcouchbase/src/views/viewreq.h +21 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +6 -6
- data/ext/libcouchbase/tests/basic/t_base64.cc +34 -6
- data/ext/libcouchbase/tests/basic/t_connstr.cc +14 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +10 -10
- data/ext/libcouchbase/tests/basic/t_host.cc +22 -2
- data/ext/libcouchbase/tests/basic/t_scram.cc +514 -0
- data/ext/libcouchbase/tests/check-all.cc +6 -2
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +64 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +27 -1
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +2 -2
- data/ext/libcouchbase/tests/iotests/t_forward.cc +8 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +124 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +1 -1
- data/ext/libcouchbase/tests/iotests/t_snappy.cc +316 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +2 -2
- data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
- data/ext/libcouchbase/tests/socktests/t_manager.cc +1 -1
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
- data/ext/libcouchbase/tools/CMakeLists.txt +1 -1
- data/ext/libcouchbase/tools/cbc-handlers.h +17 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +7 -4
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +408 -100
- data/ext/libcouchbase/tools/cbc-proxy.cc +134 -3
- data/ext/libcouchbase/tools/cbc-subdoc.cc +1 -2
- data/ext/libcouchbase/tools/cbc.cc +113 -8
- data/ext/libcouchbase/tools/common/histogram.cc +1 -0
- data/ext/libcouchbase/tools/common/options.cc +28 -1
- data/ext/libcouchbase/tools/common/options.h +5 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +36 -10
- data/ext/libcouchbase/tools/docgen/loc.h +5 -4
- data/ext/libcouchbase/tools/docgen/seqgen.h +28 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +10 -0
- data/lib/libcouchbase/n1ql.rb +6 -1
- data/lib/libcouchbase/version.rb +1 -1
- data/spec/connection_spec.rb +6 -6
- metadata +38 -5
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +0 -11
- data/ext/libcouchbase/src/mc/compress.c +0 -90
- data/ext/libcouchbase/tools/common/my_inttypes.h +0 -22
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
ADD_LIBRARY(vbucket OBJECT vbucket.c ketama.c ${SOURCE_ROOT}/contrib/cJSON/cJSON.c)
|
|
2
|
-
LCB_UTIL(vbucket)
|
|
1
|
+
ADD_LIBRARY(vbucket-lcb OBJECT vbucket.c ketama.c ${SOURCE_ROOT}/contrib/cJSON/cJSON.c)
|
|
2
|
+
LCB_UTIL(vbucket-lcb)
|
|
@@ -91,6 +91,16 @@ build_vbmap(lcbvb_CONFIG *cfg, cJSON *cj, unsigned *nitems)
|
|
|
91
91
|
return NULL;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
static void copy_address(char *buf, size_t nbuf, const char *host, lcb_U16 port)
|
|
95
|
+
{
|
|
96
|
+
if (strchr(host, ':')) {
|
|
97
|
+
// IPv6 and should be bracketed
|
|
98
|
+
snprintf(buf, nbuf, "[%s]:%d", host, port);
|
|
99
|
+
} else {
|
|
100
|
+
snprintf(buf, nbuf, "%s:%d", host, port);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
94
104
|
static lcbvb_SERVER *
|
|
95
105
|
find_server_memd(lcbvb_SERVER *servers, unsigned n, const char *s)
|
|
96
106
|
{
|
|
@@ -98,7 +108,7 @@ find_server_memd(lcbvb_SERVER *servers, unsigned n, const char *s)
|
|
|
98
108
|
for (ii = 0; ii < n; ii++) {
|
|
99
109
|
char buf[4096] = { 0 };
|
|
100
110
|
lcbvb_SERVER *cur = servers + ii;
|
|
101
|
-
|
|
111
|
+
copy_address(buf, sizeof(buf), cur->hostname, cur->svc.data);
|
|
102
112
|
if (!strncmp(s, buf, sizeof(buf))) {
|
|
103
113
|
return cur;
|
|
104
114
|
}
|
|
@@ -179,7 +189,7 @@ pair_server_list(lcbvb_CONFIG *cfg, cJSON *vbconfig)
|
|
|
179
189
|
}
|
|
180
190
|
|
|
181
191
|
/* allocate an array for the reordered server list */
|
|
182
|
-
newlist =
|
|
192
|
+
newlist = calloc(nsrv, sizeof(*cfg->servers));
|
|
183
193
|
|
|
184
194
|
for (ii = 0; ii < nsrv; ii++) {
|
|
185
195
|
char *tmp;
|
|
@@ -343,14 +353,14 @@ build_server_strings(lcbvb_CONFIG *cfg, lcbvb_SERVER *server)
|
|
|
343
353
|
/* get the authority */
|
|
344
354
|
char tmpbuf[4096];
|
|
345
355
|
|
|
346
|
-
|
|
356
|
+
copy_address(tmpbuf, sizeof(tmpbuf), server->hostname, server->svc.data);
|
|
347
357
|
server->authority = strdup(tmpbuf);
|
|
348
358
|
if (!server->authority) {
|
|
349
359
|
SET_ERRSTR(cfg, "Couldn't allocate authority");
|
|
350
360
|
return 0;
|
|
351
361
|
}
|
|
352
362
|
|
|
353
|
-
server->svc.hoststrs[LCBVB_SVCTYPE_DATA] = server->authority;
|
|
363
|
+
server->svc.hoststrs[LCBVB_SVCTYPE_DATA] = strdup(server->authority);
|
|
354
364
|
if (server->viewpath == NULL && server->svc.views) {
|
|
355
365
|
server->viewpath = malloc(strlen(cfg->bname) + 2);
|
|
356
366
|
sprintf(server->viewpath, "/%s", cfg->bname);
|
|
@@ -661,7 +671,16 @@ LIBCOUCHBASE_API
|
|
|
661
671
|
void
|
|
662
672
|
lcbvb_replace_host(lcbvb_CONFIG *cfg, const char *hoststr)
|
|
663
673
|
{
|
|
664
|
-
unsigned ii;
|
|
674
|
+
unsigned ii, copy = 0;
|
|
675
|
+
char *replacement = (char *)hoststr;
|
|
676
|
+
if (strchr(replacement, ':')) {
|
|
677
|
+
size_t len = strlen(hoststr);
|
|
678
|
+
replacement = calloc(len + 2, sizeof(char));
|
|
679
|
+
replacement[0] = '[';
|
|
680
|
+
memcpy(replacement + 1, hoststr, len);
|
|
681
|
+
replacement[len + 1] = ']';
|
|
682
|
+
copy = 1;
|
|
683
|
+
}
|
|
665
684
|
for (ii = 0; ii < cfg->nsrv; ++ii) {
|
|
666
685
|
unsigned jj;
|
|
667
686
|
lcbvb_SERVER *srv = cfg->servers + ii;
|
|
@@ -671,13 +690,17 @@ lcbvb_replace_host(lcbvb_CONFIG *cfg, const char *hoststr)
|
|
|
671
690
|
for (jj = 0; jj < 2; ++jj) {
|
|
672
691
|
unsigned kk;
|
|
673
692
|
lcbvb_SERVICES *cursvc = svcs[jj];
|
|
674
|
-
replace_hoststr(&cursvc->views_base_,
|
|
693
|
+
replace_hoststr(&cursvc->views_base_, replacement);
|
|
675
694
|
for (kk = 0; kk < LCBVB_SVCTYPE__MAX; ++kk) {
|
|
676
|
-
replace_hoststr(&cursvc->hoststrs[kk],
|
|
695
|
+
replace_hoststr(&cursvc->hoststrs[kk], replacement);
|
|
677
696
|
}
|
|
678
697
|
}
|
|
679
698
|
/* reassign authority */
|
|
680
|
-
srv->authority
|
|
699
|
+
free(srv->authority);
|
|
700
|
+
srv->authority = strdup(srv->svc.hoststrs[LCBVB_SVCTYPE_DATA]);
|
|
701
|
+
}
|
|
702
|
+
if (copy) {
|
|
703
|
+
free(replacement);
|
|
681
704
|
}
|
|
682
705
|
if (cfg->dtype == LCBVB_DIST_KETAMA) {
|
|
683
706
|
update_ketama(cfg);
|
|
@@ -730,6 +753,7 @@ lcbvb_destroy(lcbvb_CONFIG *conf)
|
|
|
730
753
|
free(srv->cbaspath);
|
|
731
754
|
free_service_strs(&srv->svc);
|
|
732
755
|
free_service_strs(&srv->svc_ssl);
|
|
756
|
+
free(srv->authority);
|
|
733
757
|
}
|
|
734
758
|
free(conf->servers);
|
|
735
759
|
free(conf->continuum);
|
|
@@ -1181,8 +1205,9 @@ lcbvb_get_hostport(lcbvb_CONFIG *cfg,
|
|
|
1181
1205
|
|
|
1182
1206
|
strp = &svc->hoststrs[type];
|
|
1183
1207
|
if (*strp == NULL) {
|
|
1184
|
-
|
|
1185
|
-
|
|
1208
|
+
size_t strn = strlen(srv->hostname) + 20;
|
|
1209
|
+
*strp = calloc(strn, sizeof(char));
|
|
1210
|
+
copy_address(*strp, strn, srv->hostname, port);
|
|
1186
1211
|
}
|
|
1187
1212
|
return *strp;
|
|
1188
1213
|
}
|
|
@@ -1260,7 +1285,6 @@ lcbvb_get_resturl(lcbvb_CONFIG *cfg, unsigned ix,
|
|
|
1260
1285
|
lcbvb_SVCTYPE svc, lcbvb_SVCMODE mode)
|
|
1261
1286
|
{
|
|
1262
1287
|
char **strp;
|
|
1263
|
-
char buf[4096];
|
|
1264
1288
|
const char *prefix;
|
|
1265
1289
|
const char *path;
|
|
1266
1290
|
|
|
@@ -1301,7 +1325,13 @@ lcbvb_get_resturl(lcbvb_CONFIG *cfg, unsigned ix,
|
|
|
1301
1325
|
if (path == NULL) {
|
|
1302
1326
|
return NULL;
|
|
1303
1327
|
} else if (!*strp) {
|
|
1304
|
-
|
|
1328
|
+
char buf[4096];
|
|
1329
|
+
if (strchr(srv->hostname, ':')) {
|
|
1330
|
+
// IPv6 and should be bracketed
|
|
1331
|
+
snprintf(buf, sizeof(buf), "%s://[%s]:%d%s", prefix, srv->hostname, port, path);
|
|
1332
|
+
} else {
|
|
1333
|
+
snprintf(buf, sizeof(buf), "%s://%s:%d%s", prefix, srv->hostname, port, path);
|
|
1334
|
+
}
|
|
1305
1335
|
*strp = strdup(buf);
|
|
1306
1336
|
}
|
|
1307
1337
|
|
|
@@ -1336,11 +1366,8 @@ LIBCOUCHBASE_API const char *lcbvb_get_error(const lcbvb_CONFIG *cfg) {
|
|
|
1336
1366
|
******************************************************************************
|
|
1337
1367
|
******************************************************************************/
|
|
1338
1368
|
|
|
1339
|
-
static void
|
|
1340
|
-
copy_service(const char *hostname,
|
|
1341
|
-
const lcbvb_SERVICES *src, lcbvb_SERVICES *dst)
|
|
1369
|
+
static void copy_service(const char *hostname, const lcbvb_SERVICES *src, lcbvb_SERVICES *dst)
|
|
1342
1370
|
{
|
|
1343
|
-
char buf[4096];
|
|
1344
1371
|
*dst = *src;
|
|
1345
1372
|
memset(&dst->hoststrs, 0, sizeof dst->hoststrs);
|
|
1346
1373
|
if (src->views_base_) {
|
|
@@ -1356,7 +1383,8 @@ copy_service(const char *hostname,
|
|
|
1356
1383
|
dst->cbas_base_ = strdup(src->cbas_base_);
|
|
1357
1384
|
}
|
|
1358
1385
|
if (dst->data) {
|
|
1359
|
-
|
|
1386
|
+
char buf[4096];
|
|
1387
|
+
copy_address(buf, sizeof(buf), hostname, dst->data);
|
|
1360
1388
|
dst->hoststrs[LCBVB_SVCTYPE_DATA] = strdup(buf);
|
|
1361
1389
|
}
|
|
1362
1390
|
}
|
|
@@ -1452,7 +1480,11 @@ lcbvb_genconfig_ex(lcbvb_CONFIG *vb,
|
|
|
1452
1480
|
|
|
1453
1481
|
copy_service(src->hostname, &src->svc, &dst->svc);
|
|
1454
1482
|
copy_service(src->hostname, &src->svc_ssl, &dst->svc_ssl);
|
|
1455
|
-
|
|
1483
|
+
{
|
|
1484
|
+
char tmpbuf[MAX_AUTHORITY_SIZE] = {0};
|
|
1485
|
+
copy_address(tmpbuf, sizeof(tmpbuf), dst->hostname, dst->svc.data);
|
|
1486
|
+
dst->authority = strdup(tmpbuf);
|
|
1487
|
+
}
|
|
1456
1488
|
}
|
|
1457
1489
|
|
|
1458
1490
|
for (ii = 0; ii < vb->nvb; ii++) {
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2014-2018 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 "viewreq.h"
|
|
2
19
|
#include "internal.h"
|
|
3
20
|
#include "sllist-inl.h"
|
|
4
21
|
|
|
@@ -100,6 +117,14 @@ docreq_handler(void *arg)
|
|
|
100
117
|
lcb_CMDGET gcmd = { 0 };
|
|
101
118
|
|
|
102
119
|
LCB_CMD_SET_KEY(&gcmd, cont->docid.iov_base, cont->docid.iov_len);
|
|
120
|
+
#ifdef LCB_TRACING
|
|
121
|
+
if (cont->parent->parent) {
|
|
122
|
+
lcb::views::ViewRequest *req = reinterpret_cast<lcb::views::ViewRequest *>(cont->parent->parent);
|
|
123
|
+
if (req->span) {
|
|
124
|
+
LCB_CMD_SET_TRACESPAN(&gcmd, req->span);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
#endif
|
|
103
128
|
cont->callback = doc_callback;
|
|
104
129
|
gcmd.cmdflags |= LCB_CMD_F_INTERNAL_CALLBACK;
|
|
105
130
|
rc = lcb_get3(instance, &cont->callback, &gcmd);
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2014-2018 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
|
+
|
|
1
18
|
/**
|
|
2
19
|
* Document request routines
|
|
3
20
|
*/
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2014-2018 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
|
+
|
|
1
18
|
#include "viewreq.h"
|
|
2
19
|
#include "sllist-inl.h"
|
|
3
20
|
#include "http/http.h"
|
|
@@ -188,6 +205,27 @@ cb_docq_throttle(lcb::docreq::Queue *q, int enabled)
|
|
|
188
205
|
ViewRequest::~ViewRequest() {
|
|
189
206
|
invoke_last();
|
|
190
207
|
|
|
208
|
+
#ifdef LCB_TRACING
|
|
209
|
+
if (span) {
|
|
210
|
+
if (htreq) {
|
|
211
|
+
lcbio_CTX *ctx = htreq->ioctx;
|
|
212
|
+
if (ctx) {
|
|
213
|
+
std::string remote;
|
|
214
|
+
if (htreq->ipv6) {
|
|
215
|
+
remote = "[" + std::string(htreq->host) + "]:" + std::string(htreq->port);
|
|
216
|
+
} else {
|
|
217
|
+
remote = std::string(htreq->host) + ":" + std::string(htreq->port);
|
|
218
|
+
}
|
|
219
|
+
lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_PEER_ADDRESS, remote.c_str());
|
|
220
|
+
lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_LOCAL_ADDRESS,
|
|
221
|
+
lcbio__inet_ntop(&ctx->sock->info->sa_local).c_str());
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
lcbtrace_span_finish(span, LCBTRACE_NOW);
|
|
225
|
+
span = NULL;
|
|
226
|
+
}
|
|
227
|
+
#endif
|
|
228
|
+
|
|
191
229
|
if (parser != NULL) {
|
|
192
230
|
delete parser;
|
|
193
231
|
}
|
|
@@ -239,7 +277,11 @@ ViewRequest::ViewRequest(lcb_t instance_, const void *cookie_,
|
|
|
239
277
|
cookie(cookie_), docq(NULL), callback(cmd->callback),
|
|
240
278
|
instance(instance_), refcount(1),
|
|
241
279
|
cmdflags(cmd->cmdflags),
|
|
242
|
-
lasterr(LCB_SUCCESS)
|
|
280
|
+
lasterr(LCB_SUCCESS)
|
|
281
|
+
#ifdef LCB_TRACING
|
|
282
|
+
, span(NULL)
|
|
283
|
+
#endif
|
|
284
|
+
{
|
|
243
285
|
|
|
244
286
|
// Validate:
|
|
245
287
|
if (cmd->nddoc == 0 || cmd->nview == 0 || callback == NULL) {
|
|
@@ -270,6 +312,15 @@ ViewRequest::ViewRequest(lcb_t instance_, const void *cookie_,
|
|
|
270
312
|
lcb_aspend_add(&instance->pendops, LCB_PENDTYPE_COUNTER, NULL);
|
|
271
313
|
|
|
272
314
|
lasterr = request_http(cmd);
|
|
315
|
+
#ifdef LCB_TRACING
|
|
316
|
+
if (lasterr == LCB_SUCCESS && instance->settings->tracer) {
|
|
317
|
+
char id[20] = {0};
|
|
318
|
+
snprintf(id, sizeof(id), "%p", (void *)this);
|
|
319
|
+
span = lcbtrace_span_start(instance->settings->tracer, LCBTRACE_OP_DISPATCH_TO_SERVER, LCBTRACE_NOW, NULL);
|
|
320
|
+
lcbtrace_span_add_tag_str(span, LCBTRACE_TAG_OPERATION_ID, id);
|
|
321
|
+
lcbtrace_span_add_system_tags(span, instance->settings, LCBTRACE_TAG_SERVICE_VIEW);
|
|
322
|
+
}
|
|
323
|
+
#endif
|
|
273
324
|
}
|
|
274
325
|
|
|
275
326
|
LIBCOUCHBASE_API
|
|
@@ -316,3 +367,15 @@ void ViewRequest::cancel() {
|
|
|
316
367
|
}
|
|
317
368
|
}
|
|
318
369
|
}
|
|
370
|
+
|
|
371
|
+
#ifdef LCB_TRACING
|
|
372
|
+
|
|
373
|
+
LIBCOUCHBASE_API
|
|
374
|
+
void lcb_view_set_parent_span(lcb_t, lcb_VIEWHANDLE handle, lcbtrace_SPAN *span)
|
|
375
|
+
{
|
|
376
|
+
if (handle && handle->span) {
|
|
377
|
+
lcbtrace_span_set_parent(handle->span, span);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
#endif
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2014-2018 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
|
+
|
|
1
18
|
#include <libcouchbase/couchbase.h>
|
|
2
19
|
#include <libcouchbase/views.h>
|
|
3
20
|
#include <libcouchbase/pktfwd.h>
|
|
@@ -60,6 +77,10 @@ struct ViewRequest : lcb::jsparse::Parser::Actions {
|
|
|
60
77
|
unsigned refcount;
|
|
61
78
|
uint32_t cmdflags;
|
|
62
79
|
lcb_error_t lasterr;
|
|
80
|
+
#ifdef LCB_TRACING
|
|
81
|
+
lcbtrace_SPAN *span;
|
|
82
|
+
#endif
|
|
83
|
+
|
|
63
84
|
};
|
|
64
85
|
|
|
65
86
|
}
|
|
@@ -3,7 +3,7 @@ IF (NOT (WIN32 AND CMAKE_COMPILER_IS_GNUCC))
|
|
|
3
3
|
SET(gtest_force_shared_crt ON CACHE BOOL "" )
|
|
4
4
|
SET(BUILD_SHARED_LIBS ON)
|
|
5
5
|
ENDIF()
|
|
6
|
-
ADD_SUBDIRECTORY(${
|
|
6
|
+
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/contrib/gtest-1.7.0 gtest)
|
|
7
7
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
|
8
8
|
|
|
9
9
|
ADD_EXECUTABLE(check-all EXCLUDE_FROM_ALL
|
|
@@ -34,10 +34,10 @@ ENDIF()
|
|
|
34
34
|
ADD_EXECUTABLE(nonio-tests EXCLUDE_FROM_ALL nonio_tests.cc ${T_BASIC_SRC})
|
|
35
35
|
|
|
36
36
|
ADD_EXECUTABLE(mc-tests EXCLUDE_FROM_ALL nonio_tests.cc ${T_MC_SRC}
|
|
37
|
-
$<TARGET_OBJECTS:mcreq> $<TARGET_OBJECTS:netbuf> $<TARGET_OBJECTS:vbucket>)
|
|
37
|
+
$<TARGET_OBJECTS:mcreq> $<TARGET_OBJECTS:mcreq-cxx> $<TARGET_OBJECTS:netbuf> $<TARGET_OBJECTS:vbucket-lcb>)
|
|
38
38
|
|
|
39
39
|
ADD_EXECUTABLE(mc-malloc-tests EXCLUDE_FROM_ALL nonio_tests.cc ${T_MC_SRC}
|
|
40
|
-
$<TARGET_OBJECTS:mcreq> $<TARGET_OBJECTS:netbuf-malloc> $<TARGET_OBJECTS:vbucket>)
|
|
40
|
+
$<TARGET_OBJECTS:mcreq> $<TARGET_OBJECTS:mcreq-cxx> $<TARGET_OBJECTS:netbuf-malloc> $<TARGET_OBJECTS:vbucket-lcb>)
|
|
41
41
|
|
|
42
42
|
ADD_EXECUTABLE(netbuf-tests
|
|
43
43
|
EXCLUDE_FROM_ALL nonio_tests.cc basic/t_netbuf.cc $<TARGET_OBJECTS:netbuf>)
|
|
@@ -75,9 +75,8 @@ ENDIF(NOT EXISTS ${PROJECT_SOURCE_DIR}/tests/CouchbaseMock.jar AND NOT LCB_NO_MO
|
|
|
75
75
|
INCLUDE_DIRECTORIES(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
|
|
76
76
|
TARGET_LINK_LIBRARIES(unit-tests couchbaseS gtest)
|
|
77
77
|
TARGET_LINK_LIBRARIES(nonio-tests couchbaseS gtest)
|
|
78
|
-
TARGET_LINK_LIBRARIES(mc-tests gtest
|
|
79
|
-
TARGET_LINK_LIBRARIES(mc-malloc-tests
|
|
80
|
-
gtest ${LCB_SNAPPY_LINK})
|
|
78
|
+
TARGET_LINK_LIBRARIES(mc-tests couchbaseS gtest)
|
|
79
|
+
TARGET_LINK_LIBRARIES(mc-malloc-tests couchbaseS gtest)
|
|
81
80
|
TARGET_LINK_LIBRARIES(netbuf-tests gtest)
|
|
82
81
|
TARGET_LINK_LIBRARIES(rdb-tests gtest)
|
|
83
82
|
TARGET_LINK_LIBRARIES(sock-tests couchbaseS gtest)
|
|
@@ -92,6 +91,7 @@ ENDIF()
|
|
|
92
91
|
ADD_CUSTOM_TARGET(alltests DEPENDS check-all unit-tests nonio-tests
|
|
93
92
|
rdb-tests sock-tests vbucket-tests mc-tests htparse-tests)
|
|
94
93
|
|
|
94
|
+
|
|
95
95
|
ADD_TEST(NAME BUILD-TESTS COMMAND ${CMAKE_COMMAND} --build "${PROJECT_BINARY_DIR}" --target alltests)
|
|
96
96
|
|
|
97
97
|
MACRO(DEFINE_MOCKTEST plugin test)
|
|
@@ -18,17 +18,35 @@
|
|
|
18
18
|
#include <gtest/gtest.h>
|
|
19
19
|
|
|
20
20
|
extern "C" {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
extern int lcb_base64_encode(const char *src, size_t nsrc, char *dst, size_t ndst);
|
|
22
|
+
extern int lcb_base64_decode(const char *src, size_t nsrc, char *dst, size_t ndst);
|
|
23
|
+
|
|
24
|
+
extern int lcb_base64_encode2(const char *src, size_t nsrc, char **dst, size_t *ndst);
|
|
25
|
+
extern int lcb_base64_decode2(const char *src, size_t nsrc, char **dst, size_t *ndst);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
class Base64 : public ::testing::Test
|
|
26
29
|
{
|
|
27
|
-
protected:
|
|
28
|
-
void validate(const char *src, const char *result)
|
|
30
|
+
protected:
|
|
31
|
+
void validate(const char *src, const char *result)
|
|
32
|
+
{
|
|
29
33
|
char dest[1024];
|
|
30
|
-
|
|
34
|
+
ASSERT_GE(lcb_base64_encode(src, strlen(src), dest, sizeof(dest)), 0);
|
|
31
35
|
EXPECT_STREQ(result, dest);
|
|
36
|
+
memset(dest, 0, sizeof(dest));
|
|
37
|
+
ASSERT_GE(lcb_base64_decode(result, strlen(result), dest, sizeof(dest)), 0);
|
|
38
|
+
EXPECT_STREQ(src, dest);
|
|
39
|
+
|
|
40
|
+
char *tmp = NULL;
|
|
41
|
+
size_t ntmp = 0;
|
|
42
|
+
ASSERT_GE(lcb_base64_encode2(src, strlen(src), &tmp, &ntmp), 0);
|
|
43
|
+
EXPECT_STREQ(result, tmp);
|
|
44
|
+
free(tmp);
|
|
45
|
+
tmp = NULL;
|
|
46
|
+
ntmp = 0;
|
|
47
|
+
ASSERT_GE(lcb_base64_decode2(result, strlen(result), &tmp, &ntmp), 0);
|
|
48
|
+
EXPECT_STREQ(src, tmp);
|
|
49
|
+
free(tmp);
|
|
32
50
|
}
|
|
33
51
|
};
|
|
34
52
|
|
|
@@ -62,7 +80,6 @@ TEST_F(Base64, testWikipediaExample)
|
|
|
62
80
|
validate("sure.", "c3VyZS4=");
|
|
63
81
|
}
|
|
64
82
|
|
|
65
|
-
|
|
66
83
|
TEST_F(Base64, testStuff)
|
|
67
84
|
{
|
|
68
85
|
// Dummy test data. It looks like the "base64" command line
|
|
@@ -79,3 +96,14 @@ TEST_F(Base64, testStuff)
|
|
|
79
96
|
validate("blahblah:bla@@h", "YmxhaGJsYWg6YmxhQEBo");
|
|
80
97
|
validate("blahblah:bla@@h\n", "YmxhaGJsYWg6YmxhQEBoCg==");
|
|
81
98
|
}
|
|
99
|
+
|
|
100
|
+
TEST_F(Base64, testTooSmallOutputBuffer)
|
|
101
|
+
{
|
|
102
|
+
const char *plain = "foobar";
|
|
103
|
+
const char *base64 = "Zm9vYmFy";
|
|
104
|
+
|
|
105
|
+
char dest[2];
|
|
106
|
+
|
|
107
|
+
ASSERT_EQ(lcb_base64_encode(plain, strlen(plain), dest, sizeof(dest)), -1);
|
|
108
|
+
ASSERT_EQ(lcb_base64_decode(base64, strlen(base64), dest, sizeof(dest)), -1);
|
|
109
|
+
}
|