libcouchbase 1.2.8 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -4
  3. data/README.md +16 -8
  4. data/ext/libcouchbase/CMakeLists.txt +34 -32
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +277 -6
  6. data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +14 -0
  7. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +2 -0
  8. data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +2 -1
  9. data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +2 -0
  10. data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +8 -1
  11. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
  12. data/ext/libcouchbase/cmake/config-cmake.h.in +14 -0
  13. data/ext/libcouchbase/cmake/configure +8 -26
  14. data/ext/libcouchbase/cmake/defs.mk.in +2 -2
  15. data/ext/libcouchbase/cmake/libcouchbase.stp.in +829 -0
  16. data/ext/libcouchbase/cmake/source_files.cmake +11 -2
  17. data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +18 -2
  18. data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +44 -2
  19. data/ext/libcouchbase/contrib/cbsasl/src/client.c +285 -73
  20. data/ext/libcouchbase/contrib/cbsasl/src/common.c +4 -0
  21. data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.c +500 -0
  22. data/ext/libcouchbase/contrib/cbsasl/src/scram-sha/scram_utils.h +99 -0
  23. data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +1 -1
  24. data/ext/libcouchbase/contrib/cliopts/cliopts.h +14 -1
  25. data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +2 -3
  26. data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +4 -0
  27. data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +7 -5
  28. data/ext/libcouchbase/contrib/snappy/snappy.cc +7 -2
  29. data/ext/libcouchbase/example/crypto/.gitignore +2 -0
  30. data/ext/libcouchbase/example/crypto/Makefile +13 -0
  31. data/ext/libcouchbase/example/crypto/common_provider.c +24 -0
  32. data/ext/libcouchbase/example/crypto/common_provider.h +31 -0
  33. data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +139 -0
  34. data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +147 -0
  35. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +281 -0
  36. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.h +29 -0
  37. data/ext/libcouchbase/example/tracing/.gitignore +2 -0
  38. data/ext/libcouchbase/example/tracing/Makefile +8 -0
  39. data/ext/libcouchbase/example/tracing/cJSON.c +1 -0
  40. data/ext/libcouchbase/example/tracing/cJSON.h +1 -0
  41. data/ext/libcouchbase/example/tracing/tracing.c +439 -0
  42. data/ext/libcouchbase/example/tracing/views.c +444 -0
  43. data/ext/libcouchbase/include/libcouchbase/auth.h +56 -4
  44. data/ext/libcouchbase/include/libcouchbase/cbft.h +8 -0
  45. data/ext/libcouchbase/include/libcouchbase/cntl-private.h +55 -1
  46. data/ext/libcouchbase/include/libcouchbase/cntl.h +101 -1
  47. data/ext/libcouchbase/include/libcouchbase/configuration.h.in +6 -0
  48. data/ext/libcouchbase/include/libcouchbase/couchbase.h +109 -6
  49. data/ext/libcouchbase/include/libcouchbase/crypto.h +140 -0
  50. data/ext/libcouchbase/include/libcouchbase/error.h +38 -2
  51. data/ext/libcouchbase/include/libcouchbase/kvbuf.h +6 -1
  52. data/ext/libcouchbase/include/libcouchbase/metrics.h +79 -0
  53. data/ext/libcouchbase/include/libcouchbase/n1ql.h +9 -0
  54. data/ext/libcouchbase/include/libcouchbase/tracing.h +319 -0
  55. data/ext/libcouchbase/include/libcouchbase/vbucket.h +1 -1
  56. data/ext/libcouchbase/include/libcouchbase/views.h +8 -0
  57. data/ext/libcouchbase/include/memcached/protocol_binary.h +40 -10
  58. data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +6 -14
  59. data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +3 -0
  60. data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +1 -0
  61. data/ext/libcouchbase/plugins/io/select/plugin-select.c +4 -1
  62. data/ext/libcouchbase/src/auth-priv.h +36 -4
  63. data/ext/libcouchbase/src/auth.cc +66 -27
  64. data/ext/libcouchbase/src/bootstrap.cc +1 -1
  65. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +12 -7
  66. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +26 -17
  67. data/ext/libcouchbase/src/bucketconfig/bc_http.h +1 -1
  68. data/ext/libcouchbase/src/bucketconfig/clconfig.h +4 -2
  69. data/ext/libcouchbase/src/bucketconfig/confmon.cc +6 -3
  70. data/ext/libcouchbase/src/cbft.cc +48 -0
  71. data/ext/libcouchbase/src/cntl.cc +138 -2
  72. data/ext/libcouchbase/src/config_static.h +17 -0
  73. data/ext/libcouchbase/src/connspec.cc +54 -6
  74. data/ext/libcouchbase/src/connspec.h +9 -1
  75. data/ext/libcouchbase/src/crypto.cc +386 -0
  76. data/ext/libcouchbase/src/ctx-log-inl.h +23 -6
  77. data/ext/libcouchbase/src/dump.cc +4 -0
  78. data/ext/libcouchbase/src/getconfig.cc +1 -2
  79. data/ext/libcouchbase/src/handler.cc +65 -27
  80. data/ext/libcouchbase/src/hostlist.cc +35 -7
  81. data/ext/libcouchbase/src/hostlist.h +7 -0
  82. data/ext/libcouchbase/src/http/http-priv.h +2 -0
  83. data/ext/libcouchbase/src/http/http.cc +77 -37
  84. data/ext/libcouchbase/src/http/http_io.cc +19 -2
  85. data/ext/libcouchbase/src/instance.cc +90 -17
  86. data/ext/libcouchbase/src/internal.h +5 -0
  87. data/ext/libcouchbase/src/lcbio/connect.cc +39 -4
  88. data/ext/libcouchbase/src/lcbio/connect.h +27 -0
  89. data/ext/libcouchbase/src/lcbio/ctx.c +49 -23
  90. data/ext/libcouchbase/src/lcbio/ioutils.cc +30 -3
  91. data/ext/libcouchbase/src/lcbio/ioutils.h +2 -0
  92. data/ext/libcouchbase/src/lcbio/manager.cc +44 -8
  93. data/ext/libcouchbase/src/lcbio/manager.h +2 -0
  94. data/ext/libcouchbase/src/lcbio/rw-inl.h +1 -0
  95. data/ext/libcouchbase/src/lcbio/ssl.h +3 -5
  96. data/ext/libcouchbase/src/logging.c +1 -1
  97. data/ext/libcouchbase/src/logging.h +2 -0
  98. data/ext/libcouchbase/src/mc/compress.cc +164 -0
  99. data/ext/libcouchbase/src/mc/compress.h +7 -12
  100. data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +5 -1
  101. data/ext/libcouchbase/src/mc/mcreq.c +11 -1
  102. data/ext/libcouchbase/src/mc/mcreq.h +35 -4
  103. data/ext/libcouchbase/src/mcserver/mcserver.cc +30 -7
  104. data/ext/libcouchbase/src/mcserver/mcserver.h +7 -0
  105. data/ext/libcouchbase/src/mcserver/negotiate.cc +103 -57
  106. data/ext/libcouchbase/src/mcserver/negotiate.h +2 -2
  107. data/ext/libcouchbase/src/mctx-helper.h +11 -0
  108. data/ext/libcouchbase/src/metrics.cc +132 -0
  109. data/ext/libcouchbase/src/n1ql/ixmgmt.cc +2 -1
  110. data/ext/libcouchbase/src/n1ql/n1ql.cc +66 -0
  111. data/ext/libcouchbase/src/newconfig.cc +9 -2
  112. data/ext/libcouchbase/src/operations/counter.cc +2 -1
  113. data/ext/libcouchbase/src/operations/durability-cas.cc +11 -0
  114. data/ext/libcouchbase/src/operations/durability-seqno.cc +3 -0
  115. data/ext/libcouchbase/src/operations/durability.cc +24 -2
  116. data/ext/libcouchbase/src/operations/durability_internal.h +19 -0
  117. data/ext/libcouchbase/src/operations/get.cc +4 -2
  118. data/ext/libcouchbase/src/operations/observe-seqno.cc +1 -0
  119. data/ext/libcouchbase/src/operations/observe.cc +113 -62
  120. data/ext/libcouchbase/src/operations/ping.cc +246 -67
  121. data/ext/libcouchbase/src/operations/remove.cc +2 -1
  122. data/ext/libcouchbase/src/operations/store.cc +17 -14
  123. data/ext/libcouchbase/src/operations/touch.cc +3 -0
  124. data/ext/libcouchbase/src/packetutils.h +68 -4
  125. data/ext/libcouchbase/src/probes.d +132 -161
  126. data/ext/libcouchbase/src/rdb/bigalloc.c +1 -1
  127. data/ext/libcouchbase/src/retryq.cc +6 -2
  128. data/ext/libcouchbase/src/rnd.cc +68 -0
  129. data/ext/libcouchbase/src/rnd.h +39 -0
  130. data/ext/libcouchbase/src/settings.c +27 -0
  131. data/ext/libcouchbase/src/settings.h +67 -3
  132. data/ext/libcouchbase/src/ssl/CMakeLists.txt +0 -12
  133. data/ext/libcouchbase/src/ssl/ssl_common.c +23 -4
  134. data/ext/libcouchbase/src/strcodecs/base64.c +141 -16
  135. data/ext/libcouchbase/src/strcodecs/strcodecs.h +16 -1
  136. data/ext/libcouchbase/src/trace.h +68 -61
  137. data/ext/libcouchbase/src/tracing/span.cc +289 -0
  138. data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +171 -0
  139. data/ext/libcouchbase/src/tracing/tracer.cc +53 -0
  140. data/ext/libcouchbase/src/tracing/tracing-internal.h +213 -0
  141. data/ext/libcouchbase/src/utilities.c +5 -0
  142. data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -2
  143. data/ext/libcouchbase/src/vbucket/vbucket.c +50 -18
  144. data/ext/libcouchbase/src/views/docreq.cc +26 -1
  145. data/ext/libcouchbase/src/views/docreq.h +17 -0
  146. data/ext/libcouchbase/src/views/viewreq.cc +64 -1
  147. data/ext/libcouchbase/src/views/viewreq.h +21 -0
  148. data/ext/libcouchbase/tests/CMakeLists.txt +6 -6
  149. data/ext/libcouchbase/tests/basic/t_base64.cc +34 -6
  150. data/ext/libcouchbase/tests/basic/t_connstr.cc +14 -0
  151. data/ext/libcouchbase/tests/basic/t_creds.cc +10 -10
  152. data/ext/libcouchbase/tests/basic/t_host.cc +22 -2
  153. data/ext/libcouchbase/tests/basic/t_scram.cc +514 -0
  154. data/ext/libcouchbase/tests/check-all.cc +6 -2
  155. data/ext/libcouchbase/tests/iotests/mock-environment.cc +64 -0
  156. data/ext/libcouchbase/tests/iotests/mock-environment.h +27 -1
  157. data/ext/libcouchbase/tests/iotests/t_confmon.cc +2 -2
  158. data/ext/libcouchbase/tests/iotests/t_forward.cc +8 -0
  159. data/ext/libcouchbase/tests/iotests/t_netfail.cc +124 -0
  160. data/ext/libcouchbase/tests/iotests/t_smoke.cc +1 -1
  161. data/ext/libcouchbase/tests/iotests/t_snappy.cc +316 -0
  162. data/ext/libcouchbase/tests/socktests/socktest.cc +2 -2
  163. data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
  164. data/ext/libcouchbase/tests/socktests/t_manager.cc +1 -1
  165. data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
  166. data/ext/libcouchbase/tools/CMakeLists.txt +1 -1
  167. data/ext/libcouchbase/tools/cbc-handlers.h +17 -0
  168. data/ext/libcouchbase/tools/cbc-n1qlback.cc +7 -4
  169. data/ext/libcouchbase/tools/cbc-pillowfight.cc +408 -100
  170. data/ext/libcouchbase/tools/cbc-proxy.cc +134 -3
  171. data/ext/libcouchbase/tools/cbc-subdoc.cc +1 -2
  172. data/ext/libcouchbase/tools/cbc.cc +113 -8
  173. data/ext/libcouchbase/tools/common/histogram.cc +1 -0
  174. data/ext/libcouchbase/tools/common/options.cc +28 -1
  175. data/ext/libcouchbase/tools/common/options.h +5 -0
  176. data/ext/libcouchbase/tools/docgen/docgen.h +36 -10
  177. data/ext/libcouchbase/tools/docgen/loc.h +5 -4
  178. data/ext/libcouchbase/tools/docgen/seqgen.h +28 -0
  179. data/lib/libcouchbase/ext/libcouchbase/enums.rb +10 -0
  180. data/lib/libcouchbase/n1ql.rb +6 -1
  181. data/lib/libcouchbase/version.rb +1 -1
  182. data/spec/connection_spec.rb +6 -6
  183. metadata +38 -5
  184. data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +0 -11
  185. data/ext/libcouchbase/src/mc/compress.c +0 -90
  186. data/ext/libcouchbase/tools/common/my_inttypes.h +0 -22
@@ -342,7 +342,7 @@ int
342
342
  lcbvb_k2vb(lcbvb_CONFIG *cfg, const void *key, lcb_SIZE n);
343
343
 
344
344
  /**
345
- * @uncomitted
345
+ * @uncommitted
346
346
  * Determines if a given server index is either a master or a replica for a
347
347
  * vbucket
348
348
  * @param vbc the configuration
@@ -295,6 +295,14 @@ LIBCOUCHBASE_API
295
295
  void
296
296
  lcb_view_cancel(lcb_t instance, lcb_VIEWHANDLE handle);
297
297
 
298
+ #ifdef LCB_TRACING
299
+ /**
300
+ * @uncommitted
301
+ */
302
+ LIBCOUCHBASE_API
303
+ void lcb_view_set_parent_span(lcb_t instance, lcb_VIEWHANDLE handle, lcbtrace_SPAN *span);
304
+ #endif
305
+
298
306
  /**@}*/
299
307
 
300
308
  #ifdef __cplusplus
@@ -69,8 +69,16 @@ extern "C"
69
69
  * See section 3.1 Magic byte
70
70
  */
71
71
  typedef enum {
72
+ /* Request packet from client to server */
72
73
  PROTOCOL_BINARY_REQ = 0x80,
73
- PROTOCOL_BINARY_RES = 0x81
74
+ /* Response packet from server to client */
75
+ PROTOCOL_BINARY_RES = 0x81,
76
+ /* Response packet from server to client containing frame extras */
77
+ PROTOCOL_BINARY_ARES = 0x18,
78
+ /* Request packet from server to client */
79
+ PROTOCOL_BINARY_SREQ = 0x82,
80
+ /* Response packet from client to server */
81
+ PROTOCOL_BINARY_SRES = 0x83
74
82
  } protocol_binary_magic;
75
83
 
76
84
  /**
@@ -152,6 +160,11 @@ extern "C"
152
160
  */
153
161
  PROTOCOL_BINARY_RESPONSE_XATTR_EINVAL = 0x87,
154
162
 
163
+ /**
164
+ * Operation attempted with an unknown collection.
165
+ */
166
+ PROTOCOL_BINARY_RESPONSE_UNKNOWN_COLLECTION = 0x88,
167
+
155
168
  /*
156
169
  * Sub-document specific responses.
157
170
  */
@@ -706,28 +719,45 @@ extern "C"
706
719
  * Definition of hello's features.
707
720
  */
708
721
  typedef enum {
709
- PROTOCOL_BINARY_FEATURE_DATATYPE = 0x01,
722
+ PROTOCOL_BINARY_FEATURE_INVALID = 0x01,
710
723
  PROTOCOL_BINARY_FEATURE_TLS = 0x2,
711
724
  PROTOCOL_BINARY_FEATURE_TCPNODELAY = 0x03,
712
725
  PROTOCOL_BINARY_FEATURE_MUTATION_SEQNO = 0x04,
713
726
  PROTOCOL_BINARY_FEATURE_TCPDELAY = 0x05,
714
727
  PROTOCOL_BINARY_FEATURE_XATTR = 0x06,
715
728
  PROTOCOL_BINARY_FEATURE_XERROR = 0x07,
716
- PROTOCOL_BINARY_FEATURE_SELECT_BUCKET = 0x08
729
+ PROTOCOL_BINARY_FEATURE_SELECT_BUCKET = 0x08,
730
+ PROTOCOL_BINARY_FEATURE_COLLECTIONS = 0x09,
731
+ PROTOCOL_BINARY_FEATURE_SNAPPY = 0x0a,
732
+ PROTOCOL_BINARY_FEATURE_JSON = 0x0b,
733
+ PROTOCOL_BINARY_FEATURE_DUPLEX = 0x0c,
734
+ PROTOCOL_BINARY_FEATURE_CLUSTERMAP_CHANGE_NOTIFICATION = 0x0d,
735
+ PROTOCOL_BINARY_FEATURE_UNORDERED_EXECUTION = 0x0e,
736
+ PROTOCOL_BINARY_FEATURE_TRACING = 0x0f
717
737
  } protocol_binary_hello_features;
718
738
 
719
- #define MEMCACHED_FIRST_HELLO_FEATURE 0x01
720
- #define MEMCACHED_TOTAL_HELLO_FEATURES 10
739
+ #define MEMCACHED_FIRST_HELLO_FEATURE 0x01
740
+ #define MEMCACHED_TOTAL_HELLO_FEATURES 15
721
741
 
742
+ // clang-format off
722
743
  #define protocol_feature_2_text(a) \
723
- (a == PROTOCOL_BINARY_FEATURE_DATATYPE) ? "Datatype" : \
744
+ (a == PROTOCOL_BINARY_FEATURE_INVALID) ? "Invalid" : \
724
745
  (a == PROTOCOL_BINARY_FEATURE_TLS) ? "TLS" : \
725
- (a == PROTOCOL_BINARY_FEATURE_TCPNODELAY) ? "TCP NODELAY" : \
746
+ (a == PROTOCOL_BINARY_FEATURE_TCPNODELAY) ? "TCP nodelay" : \
726
747
  (a == PROTOCOL_BINARY_FEATURE_MUTATION_SEQNO) ? "Mutation seqno" : \
727
- (a == PROTOCOL_BINARY_FEATURE_TCPDELAY) ? "TCP DELAY" : \
748
+ (a == PROTOCOL_BINARY_FEATURE_TCPDELAY) ? "TCP delay" : \
728
749
  (a == PROTOCOL_BINARY_FEATURE_XATTR) ? "XATTR" : \
729
- (a == PROTOCOL_BINARY_FEATURE_XERROR) ? "Error Map": \
730
- (a == PROTOCOL_BINARY_FEATURE_SELECT_BUCKET) ? "Select Bucket": "Unknown"
750
+ (a == PROTOCOL_BINARY_FEATURE_XERROR) ? "XERROR": \
751
+ (a == PROTOCOL_BINARY_FEATURE_SELECT_BUCKET) ? "Select bucket": \
752
+ (a == PROTOCOL_BINARY_FEATURE_COLLECTIONS) ? "Collections": \
753
+ (a == PROTOCOL_BINARY_FEATURE_SNAPPY) ? "Snappy": \
754
+ (a == PROTOCOL_BINARY_FEATURE_JSON) ? "JSON": \
755
+ (a == PROTOCOL_BINARY_FEATURE_DUPLEX) ? "Duplex": \
756
+ (a == PROTOCOL_BINARY_FEATURE_CLUSTERMAP_CHANGE_NOTIFICATION) ? "Clustermap change notification": \
757
+ (a == PROTOCOL_BINARY_FEATURE_UNORDERED_EXECUTION) ? "Unordered execution": \
758
+ (a == PROTOCOL_BINARY_FEATURE_TRACING) ? "Tracing": \
759
+ "Unknown"
760
+ // clang-format on
731
761
 
732
762
  /**
733
763
  * The HELLO command is used by the client and the server to agree
@@ -5,12 +5,12 @@ Release: @RELEASE@%{?dist}
5
5
  Vendor: Couchbase, Inc.
6
6
  Packager: Couchbase SDK Team <support@couchbase.com>
7
7
  License: ASL 2.0
8
- Group: System Environment/Libraries
9
8
  BuildRequires: gcc, gcc-c++
10
9
  BuildRequires: cmake >= 2.8.9
11
10
  BuildRequires: pkgconfig(libevent) >= 2
12
11
  BuildRequires: libev-devel >= 3
13
12
  BuildRequires: openssl-devel
13
+ BuildRequires: systemtap-sdt-devel, systemtap-devel
14
14
  URL: https://developer.couchbase.com/server/other-products/release-notes-archives/c-sdk
15
15
  Source: https://packages.couchbase.com/clients/c/@TARREDAS@.tar.gz
16
16
  BuildRoot: %{_topdir}/build/@TARREDAS@
@@ -24,21 +24,18 @@ Suggests: %{name}2-tools%{_isa} = %{version}-%{release}
24
24
  This is the client and protocol library for Couchbase project.
25
25
 
26
26
  %package -n %{name}2-libevent
27
- Group: System Environment/Libraries
28
27
  Summary: Couchbase client library - libevent IO back-end
29
28
  Requires: %{name}2-core%{?_isa} = %{version}-%{release}
30
29
  %description -n %{name}2-libevent
31
30
  This package provides libevent back-end for libcouchbase
32
31
 
33
32
  %package -n %{name}2-libev
34
- Group: System Environment/Libraries
35
33
  Summary: Couchbase client library - libev IO back-end
36
34
  Requires: %{name}2-core%{?_isa} = %{version}-%{release}
37
35
  %description -n %{name}2-libev
38
36
  This package provides libev back-end for libcouchbase
39
37
 
40
38
  %package -n %{name}2-core
41
- Group: System Environment/Libraries
42
39
  Summary: Couchbase client library - core
43
40
  Provides: %{name}2%{?_isa} = %{version}-%{release}
44
41
  %description -n %{name}2-core
@@ -50,21 +47,19 @@ installed back-end. It is also possible to integrate another IO back-end
50
47
  or write your own.
51
48
 
52
49
  %package -n %{name}2-bin
53
- Group: Development/Tools
54
50
  Summary: Couchbase Client Tools
55
51
  Requires: %{name}2-core%{?_isa} = %{version}-%{release}
56
52
  %description -n %{name}2-bin
57
53
  This is the CLI tools Couchbase project.
58
54
 
59
55
  %package devel
60
- Group: Development/Libraries
61
56
  Summary: Couchbase Client & Protocol Library - Header files
62
57
  Requires: %{name}2-core%{?_isa} = %{version}-%{release}
63
58
  %description devel
64
59
  Development files for the Couchbase Client & Protocol Library
65
60
 
66
61
  %prep
67
- %setup -q -n @TARREDAS@
62
+ %autosetup -p1 -n@TARREDAS@
68
63
  %cmake -DLCB_NO_MOCK=1 -DLCB_BUILD_LIBUV=OFF
69
64
 
70
65
  %build
@@ -74,7 +69,7 @@ Development files for the Couchbase Client & Protocol Library
74
69
  %make_install
75
70
 
76
71
  %check
77
- make test
72
+ make %{_smp_mflags} alltests && make test
78
73
 
79
74
  %clean
80
75
  %{__rm} -rf %{buildroot}
@@ -84,26 +79,23 @@ make test
84
79
  %postun -n %{name}2-core -p /sbin/ldconfig
85
80
 
86
81
  %files -n %{name}2-core
87
- %defattr(-, root, root)
88
82
  %{_libdir}/%{name}.so.*
89
- %doc README.markdown LICENSE RELEASE_NOTES.markdown
83
+ %doc README.markdown RELEASE_NOTES.markdown
84
+ %license LICENSE
85
+ %{_datadir}/systemtap/tapset/libcouchbase.so*
90
86
 
91
87
  %files -n %{name}2-libevent
92
- %defattr(-, root, root)
93
88
  %{_libdir}/%{name}_libevent.so
94
89
 
95
90
  %files -n %{name}2-libev
96
- %defattr(-, root, root)
97
91
  %{_libdir}/%{name}_libev.so
98
92
 
99
93
  %files -n %{name}2-bin
100
- %defattr(-, root, root)
101
94
  %{_bindir}/cbc*
102
95
  %{_mandir}/man1/cbc*.1*
103
96
  %{_mandir}/man4/cbcrc*.4*
104
97
 
105
98
  %files devel
106
- %defattr(-, root, root)
107
99
  %{_includedir}/%{name}
108
100
  %{_libdir}/%{name}.so
109
101
  %{_libdir}/pkgconfig/%{name}.pc
@@ -27,6 +27,9 @@
27
27
  #include <stdlib.h>
28
28
  #include <string.h>
29
29
  #include <sys/types.h>
30
+ #ifndef _WIN32
31
+ #include <unistd.h>
32
+ #endif
30
33
 
31
34
  #include "libuv_compat.h"
32
35
 
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  #include "plugin-internal.h"
19
+ #include <libcouchbase/plugins/io/bsdio-inl.c>
19
20
 
20
21
  static my_uvreq_t *alloc_uvreq(my_sockdata_t *sock, generic_callback_t callback);
21
22
  static void set_last_error(my_iops_t *io, int error);
@@ -342,7 +342,10 @@ sel_destroy_iops(struct lcb_io_opt_st *iops)
342
342
  sel_EVENT *ev;
343
343
  sel_TIMER *tm;
344
344
 
345
- assert(io->event_loop == 0);
345
+ if (io->event_loop != 0) {
346
+ fprintf(stderr, "WARN: libcouchbase(plugin-select): the event loop might be still active, but it still try to "
347
+ "free resources\n");
348
+ }
346
349
  LCB_LIST_SAFE_FOR(ii, nn, &io->events.list) {
347
350
  ev = LCB_LIST_ITEM(ii, sel_EVENT, list);
348
351
  sel_event_free(iops, ev);
@@ -1,3 +1,20 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2017-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
  #ifndef LCB_AUTH_PRIV_H
2
19
  #define LCB_AUTH_PRIV_H
3
20
  #include <libcouchbase/auth.h>
@@ -17,17 +34,22 @@ public:
17
34
  const std::string& password() const { return m_password; }
18
35
 
19
36
  // Get the username and password for a specific bucket
20
- const std::string& username_for(const char *bucket) const;
21
- const std::string& password_for(const char *bucket) const;
37
+ const std::string username_for(const char *host, const char *port, const char *bucket) const;
38
+ const std::string password_for(const char *host, const char *port, const char *bucket) const;
22
39
 
23
40
  const Map& buckets() const { return m_buckets; }
24
- Authenticator() : m_refcount(1), m_mode(LCBAUTH_MODE_CLASSIC) {}
41
+ Authenticator() : m_refcount(1), m_mode(LCBAUTH_MODE_CLASSIC), m_usercb(NULL), m_passcb(NULL), m_cookie(NULL)
42
+ {
43
+ }
25
44
  Authenticator(const Authenticator&);
26
45
 
27
46
  size_t refcount() const { return m_refcount; }
28
47
  void incref() { ++m_refcount; }
29
48
  void decref() { if (!--m_refcount) { delete this; } }
30
49
  lcb_error_t set_mode(lcbauth_MODE mode_) {
50
+ if (mode_ == LCBAUTH_MODE_DYNAMIC && (m_usercb == NULL || m_passcb == NULL)) {
51
+ return LCB_EINVAL;
52
+ }
31
53
  if (m_buckets.size() || m_username.size() || m_password.size()) {
32
54
  return LCB_ERROR;
33
55
  } else {
@@ -40,13 +62,23 @@ public:
40
62
  lcb_error_t add(const std::string& user, const std::string& pass, int flags) {
41
63
  return add(user.c_str(), pass.c_str(), flags);
42
64
  }
65
+ lcb_error_t set_callbacks(void *cookie, lcb_AUTHCALLBACK usercb, lcb_AUTHCALLBACK passcb)
66
+ {
67
+ m_usercb = usercb;
68
+ m_passcb = passcb;
69
+ m_cookie = cookie;
70
+ return LCB_SUCCESS;
71
+ }
43
72
 
44
- private:
73
+ private:
45
74
  Map m_buckets;
46
75
  std::string m_username;
47
76
  std::string m_password;
48
77
  size_t m_refcount;
49
78
  lcbauth_MODE m_mode;
79
+ lcb_AUTHCALLBACK m_usercb;
80
+ lcb_AUTHCALLBACK m_passcb;
81
+ void *m_cookie;
50
82
  };
51
83
  }
52
84
  #endif
@@ -1,3 +1,20 @@
1
+ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2017-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 "auth-priv.h"
3
20
 
@@ -18,6 +35,10 @@ lcbauth_add_pass(lcb_AUTHENTICATOR *auth, const char *u, const char *p, int flag
18
35
  lcb_error_t
19
36
  Authenticator::add(const char *u, const char *p, int flags)
20
37
  {
38
+ if (!u) {
39
+ return LCB_EINVAL;
40
+ }
41
+
21
42
  if (!(flags & (LCBAUTH_F_BUCKET|LCBAUTH_F_CLUSTER))) {
22
43
  return LCB_EINVAL;
23
44
  }
@@ -49,33 +70,45 @@ Authenticator::add(const char *u, const char *p, int flags)
49
70
 
50
71
  static const std::string EmptyString;
51
72
 
52
- const std::string&
53
- Authenticator::username_for(const char *bucket) const {
54
- if (m_mode == LCBAUTH_MODE_CLASSIC) {
55
- // Find bucket specific credentials:
56
- const Map::const_iterator it = m_buckets.find(bucket);
57
- if (it == m_buckets.end()) {
58
- return EmptyString;
59
- } else {
60
- return it->first;
61
- }
62
- } else {
63
- return m_username;
73
+ const std::string Authenticator::username_for(const char *host, const char *port, const char *bucket) const
74
+ {
75
+ switch (m_mode) {
76
+ case LCBAUTH_MODE_RBAC:
77
+ return m_username;
78
+ case LCBAUTH_MODE_DYNAMIC:
79
+ if (m_usercb != NULL) {
80
+ return m_usercb(m_cookie, host, port, bucket);
81
+ }
82
+ break;
83
+ case LCBAUTH_MODE_CLASSIC:
84
+ // Find bucket specific credentials:
85
+ const Map::const_iterator it = m_buckets.find(bucket);
86
+ if (it != m_buckets.end()) {
87
+ return it->first;
88
+ }
89
+ break;
64
90
  }
91
+ return EmptyString;
65
92
  }
66
93
 
67
- const std::string&
68
- Authenticator::password_for(const char *bucket) const {
69
- if (m_mode == LCBAUTH_MODE_CLASSIC) {
70
- const Map::const_iterator it = m_buckets.find(bucket);
71
- if (it == m_buckets.end()) {
72
- return EmptyString;
73
- } else {
74
- return it->second;
75
- }
76
- } else {
77
- return m_password;
94
+ const std::string Authenticator::password_for(const char *host, const char *port, const char *bucket) const
95
+ {
96
+ switch (m_mode) {
97
+ case LCBAUTH_MODE_RBAC:
98
+ return m_password;
99
+ case LCBAUTH_MODE_DYNAMIC:
100
+ if (m_passcb != NULL) {
101
+ return m_passcb(m_cookie, host, port, bucket);
102
+ }
103
+ break;
104
+ case LCBAUTH_MODE_CLASSIC:
105
+ const Map::const_iterator it = m_buckets.find(bucket);
106
+ if (it != m_buckets.end()) {
107
+ return it->second;
108
+ }
109
+ break;
78
110
  }
111
+ return EmptyString;
79
112
  }
80
113
 
81
114
  void
@@ -90,10 +123,10 @@ lcbauth_unref(lcb_AUTHENTICATOR *auth)
90
123
  auth->decref();
91
124
  }
92
125
 
93
- Authenticator::Authenticator(const Authenticator& other)
94
- : m_buckets(other.m_buckets), m_username(other.m_username),
95
- m_password(other.m_password), m_refcount(1),
96
- m_mode(other.m_mode) {
126
+ Authenticator::Authenticator(const Authenticator &other)
127
+ : m_buckets(other.m_buckets), m_username(other.m_username), m_password(other.m_password), m_refcount(1),
128
+ m_mode(other.m_mode), m_usercb(other.m_usercb), m_passcb(other.m_passcb), m_cookie(other.m_cookie)
129
+ {
97
130
  }
98
131
 
99
132
  lcb_AUTHENTICATOR *
@@ -105,3 +138,9 @@ lcb_error_t
105
138
  lcbauth_set_mode(lcb_AUTHENTICATOR *src, lcbauth_MODE mode) {
106
139
  return src->set_mode(mode);
107
140
  }
141
+
142
+ lcb_error_t lcbauth_set_callbacks(lcb_AUTHENTICATOR *auth, void *cookie, lcb_AUTHCALLBACK usercb,
143
+ lcb_AUTHCALLBACK passcb)
144
+ {
145
+ return auth->set_callbacks(cookie, usercb, passcb);
146
+ }
@@ -204,7 +204,7 @@ lcb_error_t Bootstrap::bootstrap(unsigned options) {
204
204
  next_ts += LCB_US2NS(LCBT_SETTING(parent, weird_things_delay));
205
205
  if (now < next_ts && errcounter < errthresh) {
206
206
  lcb_log(LOGARGS(parent, INFO),
207
- "Not requesting a config refresh because of throttling parameters. Next refresh possible in %ums or %u errors. "
207
+ "Not requesting a config refresh because of throttling parameters. Next refresh possible in %" PRIu64 "ms or %u errors. "
208
208
  "See LCB_CNTL_CONFDELAY_THRESH and LCB_CNTL_CONFERRTHRESH to modify the throttling settings",
209
209
  LCB_NS2US(next_ts-now)/1000, (unsigned)errthresh-errcounter);
210
210
  return LCB_SUCCESS;
@@ -29,9 +29,10 @@
29
29
  #include <lcbio/timer-cxx.h>
30
30
  #include <lcbio/ssl.h>
31
31
  #include "ctx-log-inl.h"
32
+
33
+ #define LOGFMT CTX_LOGFMT
34
+ #define LOGID(p) CTX_LOGID(p->ioctx)
32
35
  #define LOGARGS(cccp, lvl) cccp->parent->settings, "cccp", LCB_LOG_##lvl, __FILE__, __LINE__
33
- #define LOGFMT "<%s:%s> "
34
- #define LOGID(cccp) get_ctx_host(cccp->ioctx), get_ctx_port(cccp->ioctx)
35
36
 
36
37
  struct CccpCookie;
37
38
 
@@ -140,13 +141,15 @@ CccpProvider::schedule_next_request(lcb_error_t err, bool can_rollover)
140
141
  lcb::Server* server = instance->find_server(*next_host);
141
142
  if (server) {
142
143
  cmdcookie = new CccpCookie(this);
143
- lcb_log(LOGARGS(this, DEBUG), "Re-Issuing CCCP Command on server struct %p (%s:%s)", (void*)server, next_host->host, next_host->port);
144
+ lcb_log(LOGARGS(this, TRACE), "Re-Issuing CCCP Command on server struct %p (" LCB_HOST_FMT ")", (void *)server,
145
+ LCB_HOST_ARG(this->parent->settings, next_host));
144
146
  timer.rearm(settings().config_node_timeout);
145
147
  instance->request_config(cmdcookie, server);
146
148
 
147
149
  } else {
148
150
 
149
- lcb_log(LOGARGS(this, INFO), "Requesting connection to node %s:%s for CCCP configuration", next_host->host, next_host->port);
151
+ lcb_log(LOGARGS(this, INFO), "Requesting connection to node " LCB_HOST_FMT " for CCCP configuration",
152
+ LCB_HOST_ARG(this->parent->settings, next_host));
150
153
  creq = instance->memd_sockpool->get(*next_host,
151
154
  settings().config_node_timeout,
152
155
  on_connected, this);
@@ -262,6 +265,7 @@ on_connected(lcbio_SOCKET *sock, void *data, lcb_error_t err, lcbio_OSERR)
262
265
  ioprocs.cb_read = io_read_handler;
263
266
  cccp->ioctx = lcbio_ctx_new(sock, data, &ioprocs);
264
267
  cccp->ioctx->subsys = "bc_cccp";
268
+ sock->service = LCBIO_SERVICE_CFG;
265
269
  cccp->request_config();
266
270
  }
267
271
 
@@ -324,7 +328,7 @@ CccpProvider::config_updated(lcbvb_CONFIG *vbc)
324
328
  const char *mcaddr = lcbvb_get_hostport(vbc,
325
329
  ii, LCBVB_SVCTYPE_DATA, mode);
326
330
  if (!mcaddr) {
327
- lcb_log(LOGARGS(this, DEBUG), "Node %lu has no data service", ii);
331
+ lcb_log(LOGARGS(this, DEBUG), "Node %lu has no data service", (unsigned long int)ii);
328
332
  continue;
329
333
  }
330
334
  nodes->add(mcaddr, LCB_CONFIG_MCD_PORT);
@@ -383,7 +387,7 @@ CccpProvider::on_io_read()
383
387
  return_error(LCB_PROTOCOL_ERROR);
384
388
  }
385
389
 
386
- std::string jsonstr(resp.body<const char*>(), resp.bodylen());
390
+ std::string jsonstr(resp.value(), resp.vallen());
387
391
  std::string hoststr(lcbio_get_host(lcbio_ctx_sock(ioctx))->host);
388
392
 
389
393
  resp.release(ioctx);
@@ -429,7 +433,8 @@ void CccpProvider::dump(FILE *fp) const {
429
433
 
430
434
  for (size_t ii = 0; ii < nodes->size(); ii++) {
431
435
  const lcb_host_t &curhost = (*nodes)[ii];
432
- fprintf(fp, "CCCP NODE: %s:%s\n", curhost.host, curhost.port);
436
+ lcb_settings *dummy = NULL;
437
+ fprintf(fp, "CCCP NODE: " LCB_HOST_FMT "\n", LCB_HOST_ARG(dummy, &curhost));
433
438
  }
434
439
  fprintf(fp, "## END CCCP PROVIDER DUMP ##\n");
435
440
  }