libcouchbase 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.travis.yml +35 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +389 -0
- data/Rakefile +75 -0
- data/ext/README.md +6 -0
- data/ext/Rakefile +20 -0
- data/ext/libcouchbase/.gitignore +130 -0
- data/ext/libcouchbase/.travis.yml +19 -0
- data/ext/libcouchbase/CMakeLists.txt +429 -0
- data/ext/libcouchbase/CONTRIBUTING.md +124 -0
- data/ext/libcouchbase/LICENSE +202 -0
- data/ext/libcouchbase/README.markdown +163 -0
- data/ext/libcouchbase/RELEASE_NOTES.markdown +2691 -0
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +27 -0
- data/ext/libcouchbase/cmake/Modules/CopyPDB.cmake +42 -0
- data/ext/libcouchbase/cmake/Modules/DistScript.cmake +17 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +20 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseHdrHistogram.cmake +15 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibev.cmake +73 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +52 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +56 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +29 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +133 -0
- data/ext/libcouchbase/cmake/Modules/GetPlatformCCInfo.cmake +45 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +70 -0
- data/ext/libcouchbase/cmake/config-cmake.h.in +60 -0
- data/ext/libcouchbase/cmake/configure +357 -0
- data/ext/libcouchbase/cmake/defs.mk.in +8 -0
- data/ext/libcouchbase/cmake/dtrace-instr-link.pl +38 -0
- data/ext/libcouchbase/cmake/source_files.cmake +73 -0
- data/ext/libcouchbase/configure.pl +1 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +624 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.h +158 -0
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +9 -0
- data/ext/libcouchbase/contrib/cbsasl/COPYING +202 -0
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +217 -0
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +205 -0
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +46 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.c +67 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.h +33 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.c +296 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.h +45 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.c +573 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.h +15 -0
- data/ext/libcouchbase/contrib/cbsasl/src/util.h +31 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +2 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.c +747 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +493 -0
- data/ext/libcouchbase/contrib/genhash/genhash.c +372 -0
- data/ext/libcouchbase/contrib/genhash/genhash.h +235 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CHANGES +157 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CMakeLists.txt +252 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CONTRIBUTORS +37 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/LICENSE +28 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/MINIFY.sh +15 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/README +435 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/cmake/internal_utils.cmake +227 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-death-test.h +294 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-message.h +250 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h +1421 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h.pump +487 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-printers.h +855 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-spi.h +232 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-test-part.h +179 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-typed-test.h +259 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest.h +2291 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_pred_impl.h +358 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_prod.h +58 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-death-test-internal.h +319 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-filepath.h +206 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-internal.h +1158 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-linked_ptr.h +233 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h +5143 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util.h +619 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-port.h +1947 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-string.h +167 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h +1012 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h.pump +339 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h +3331 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h.pump +297 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-all.cc +48 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-death-test.cc +1344 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-filepath.cc +382 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-internal-inl.h +1218 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-port.cc +805 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-printers.cc +363 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-test-part.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-typed-test.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest.cc +5015 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest_main.cc +38 -0
- data/ext/libcouchbase/contrib/http_parser/LICENSE-MIT +23 -0
- data/ext/libcouchbase/contrib/http_parser/README.md +178 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.c +2060 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.h +321 -0
- data/ext/libcouchbase/contrib/jsonsl/LICENSE +20 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.c +1452 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.h +971 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/CMakeLists.txt +6 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/LICENSE +55 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp-forwards.h +255 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4892 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.h +1961 -0
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +8 -0
- data/ext/libcouchbase/contrib/snappy/COPYING +28 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.cc +90 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.h +138 -0
- data/ext/libcouchbase/contrib/snappy/snappy-internal.h +150 -0
- data/ext/libcouchbase/contrib/snappy/snappy-lcb-msvc.h +5 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +71 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.h +137 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.h +491 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +98 -0
- data/ext/libcouchbase/contrib/snappy/snappy.cc +1307 -0
- data/ext/libcouchbase/contrib/snappy/snappy.h +184 -0
- data/ext/libcouchbase/contrib/win32-defs/iocpdefs.h +133 -0
- data/ext/libcouchbase/contrib/win32-defs/mingwdefs.h +4396 -0
- data/ext/libcouchbase/contrib/win32-defs/win_stdint.h +258 -0
- data/ext/libcouchbase/example/CMakeLists.txt +37 -0
- data/ext/libcouchbase/example/README.markdown +47 -0
- data/ext/libcouchbase/example/db/db.c +167 -0
- data/ext/libcouchbase/example/db/vb.c +227 -0
- data/ext/libcouchbase/example/instancepool/main.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.h +69 -0
- data/ext/libcouchbase/example/libeventdirect/main.c +148 -0
- data/ext/libcouchbase/example/mcc/mcc.cc +246 -0
- data/ext/libcouchbase/example/minimal/minimal.c +130 -0
- data/ext/libcouchbase/example/observe/observe.c +146 -0
- data/ext/libcouchbase/example/subdoc/subdoc-multi.cc +132 -0
- data/ext/libcouchbase/example/subdoc/subdoc-simple.cc +191 -0
- data/ext/libcouchbase/example/tick/tick.c +119 -0
- data/ext/libcouchbase/example/views/views-example.cc +83 -0
- data/ext/libcouchbase/include/libcouchbase/_cxxwrap.h +150 -0
- data/ext/libcouchbase/include/libcouchbase/api-legacy.h +1689 -0
- data/ext/libcouchbase/include/libcouchbase/api3.h +2 -0
- data/ext/libcouchbase/include/libcouchbase/assert.h +44 -0
- data/ext/libcouchbase/include/libcouchbase/cbft.h +109 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +356 -0
- data/ext/libcouchbase/include/libcouchbase/cntl.h +937 -0
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +23 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +3677 -0
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +300 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +595 -0
- data/ext/libcouchbase/include/libcouchbase/http.h +1 -0
- data/ext/libcouchbase/include/libcouchbase/iops.h +1050 -0
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +263 -0
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +132 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +364 -0
- data/ext/libcouchbase/include/libcouchbase/pktfwd.h +270 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +367 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr-inl.c +76 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr.h +199 -0
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +312 -0
- data/ext/libcouchbase/include/libcouchbase/sysdefs.h +98 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +643 -0
- data/ext/libcouchbase/include/libcouchbase/views.h +298 -0
- data/ext/libcouchbase/include/libcouchbase/visibility.h +65 -0
- data/ext/libcouchbase/include/memcached/COPYING +30 -0
- data/ext/libcouchbase/include/memcached/README +10 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +1916 -0
- data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
- data/ext/libcouchbase/packaging/README +7 -0
- data/ext/libcouchbase/packaging/abicheck/.gitignore +4 -0
- data/ext/libcouchbase/packaging/abicheck/Makefile +17 -0
- data/ext/libcouchbase/packaging/abicheck/README.md +27 -0
- data/ext/libcouchbase/packaging/abicheck/template.xml +3 -0
- data/ext/libcouchbase/packaging/deb/compat +1 -0
- data/ext/libcouchbase/packaging/deb/control +73 -0
- data/ext/libcouchbase/packaging/deb/copyright +10 -0
- data/ext/libcouchbase/packaging/deb/libcouchbase-dev.docs +3 -0
- data/ext/libcouchbase/packaging/deb/package.mk +31 -0
- data/ext/libcouchbase/packaging/deb/rules +46 -0
- data/ext/libcouchbase/packaging/deb/source/format +1 -0
- data/ext/libcouchbase/packaging/distinfo/README +1 -0
- data/ext/libcouchbase/packaging/distinfo/distinfo.cmake.in +4 -0
- data/ext/libcouchbase/packaging/dllversion.rc.in +39 -0
- data/ext/libcouchbase/packaging/libcouchbase.pc.in +10 -0
- data/ext/libcouchbase/packaging/nuget/libcouchbase.autopkg +76 -0
- data/ext/libcouchbase/packaging/parse-git-describe.pl +166 -0
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +108 -0
- data/ext/libcouchbase/packaging/rpm/package.mk +40 -0
- data/ext/libcouchbase/plugins/io/iocp/CMakeLists.txt +9 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.c +466 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.h +217 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_loop.c +295 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_timer.c +79 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_util.c +229 -0
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +65 -0
- data/ext/libcouchbase/plugins/io/libev/plugin-libev.c +289 -0
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libevent/libevent_io_opts.h +67 -0
- data/ext/libcouchbase/plugins/io/libevent/plugin-libevent.c +292 -0
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +42 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +212 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_io_opts.h +118 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +148 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +648 -0
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +11 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +448 -0
- data/ext/libcouchbase/plugins/io/select/select_io_opts.h +39 -0
- data/ext/libcouchbase/src/README.md +103 -0
- data/ext/libcouchbase/src/aspend.h +106 -0
- data/ext/libcouchbase/src/auth.cc +74 -0
- data/ext/libcouchbase/src/auth.h +54 -0
- data/ext/libcouchbase/src/bootstrap.c +269 -0
- data/ext/libcouchbase/src/bootstrap.h +129 -0
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +495 -0
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +82 -0
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +681 -0
- data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
- data/ext/libcouchbase/src/callbacks.c +378 -0
- data/ext/libcouchbase/src/cbft.cc +210 -0
- data/ext/libcouchbase/src/cntl.cc +847 -0
- data/ext/libcouchbase/src/config_static.h +159 -0
- data/ext/libcouchbase/src/connspec.cc +462 -0
- data/ext/libcouchbase/src/connspec.h +105 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +27 -0
- data/ext/libcouchbase/src/dump.c +98 -0
- data/ext/libcouchbase/src/getconfig.c +100 -0
- data/ext/libcouchbase/src/gethrtime.c +109 -0
- data/ext/libcouchbase/src/handler.c +922 -0
- data/ext/libcouchbase/src/hashset.c +164 -0
- data/ext/libcouchbase/src/hashset.h +86 -0
- data/ext/libcouchbase/src/hashtable.c +75 -0
- data/ext/libcouchbase/src/hdr_timings.c +92 -0
- data/ext/libcouchbase/src/hostlist.cc +301 -0
- data/ext/libcouchbase/src/hostlist.h +171 -0
- data/ext/libcouchbase/src/http/http-priv.h +307 -0
- data/ext/libcouchbase/src/http/http.cc +633 -0
- data/ext/libcouchbase/src/http/http.h +34 -0
- data/ext/libcouchbase/src/http/http_io.cc +307 -0
- data/ext/libcouchbase/src/instance.cc +722 -0
- data/ext/libcouchbase/src/internal.h +244 -0
- data/ext/libcouchbase/src/iofactory.c +575 -0
- data/ext/libcouchbase/src/jsparse/parser.cc +519 -0
- data/ext/libcouchbase/src/jsparse/parser.h +173 -0
- data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +199 -0
- data/ext/libcouchbase/src/lcbio/connect.c +557 -0
- data/ext/libcouchbase/src/lcbio/connect.h +364 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +611 -0
- data/ext/libcouchbase/src/lcbio/ctx.h +405 -0
- data/ext/libcouchbase/src/lcbio/iotable.c +290 -0
- data/ext/libcouchbase/src/lcbio/iotable.h +84 -0
- data/ext/libcouchbase/src/lcbio/ioutils.c +350 -0
- data/ext/libcouchbase/src/lcbio/ioutils.h +203 -0
- data/ext/libcouchbase/src/lcbio/lcbio.h +51 -0
- data/ext/libcouchbase/src/lcbio/manager.c +584 -0
- data/ext/libcouchbase/src/lcbio/manager.h +156 -0
- data/ext/libcouchbase/src/lcbio/protoctx.c +84 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +115 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +149 -0
- data/ext/libcouchbase/src/lcbio/timer-ng.h +179 -0
- data/ext/libcouchbase/src/lcbio/timer.c +132 -0
- data/ext/libcouchbase/src/legacy.c +430 -0
- data/ext/libcouchbase/src/list.c +144 -0
- data/ext/libcouchbase/src/list.h +127 -0
- data/ext/libcouchbase/src/logging.c +244 -0
- data/ext/libcouchbase/src/logging.h +86 -0
- data/ext/libcouchbase/src/mc/compress.c +90 -0
- data/ext/libcouchbase/src/mc/compress.h +61 -0
- data/ext/libcouchbase/src/mc/forward.c +186 -0
- data/ext/libcouchbase/src/mc/forward.h +90 -0
- data/ext/libcouchbase/src/mc/iovcursor-inl.h +279 -0
- data/ext/libcouchbase/src/mc/iovcursor.h +66 -0
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +111 -0
- data/ext/libcouchbase/src/mc/mcreq.c +954 -0
- data/ext/libcouchbase/src/mc/mcreq.h +977 -0
- data/ext/libcouchbase/src/mcserver/mcserver.c +784 -0
- data/ext/libcouchbase/src/mcserver/mcserver.h +121 -0
- data/ext/libcouchbase/src/mcserver/negotiate.c +656 -0
- data/ext/libcouchbase/src/mcserver/negotiate.h +119 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +860 -0
- data/ext/libcouchbase/src/n1ql/n1ql-internal.h +22 -0
- data/ext/libcouchbase/src/n1ql/n1ql.cc +729 -0
- data/ext/libcouchbase/src/n1ql/params.cc +215 -0
- data/ext/libcouchbase/src/netbuf/netbuf-defs.h +89 -0
- data/ext/libcouchbase/src/netbuf/netbuf-mblock.h +235 -0
- data/ext/libcouchbase/src/netbuf/netbuf.c +929 -0
- data/ext/libcouchbase/src/netbuf/netbuf.h +452 -0
- data/ext/libcouchbase/src/newconfig.c +385 -0
- data/ext/libcouchbase/src/nodeinfo.cc +194 -0
- data/ext/libcouchbase/src/operations/cbflush.c +71 -0
- data/ext/libcouchbase/src/operations/counter.c +116 -0
- data/ext/libcouchbase/src/operations/durability-cas.c +224 -0
- data/ext/libcouchbase/src/operations/durability-seqno.c +157 -0
- data/ext/libcouchbase/src/operations/durability.c +668 -0
- data/ext/libcouchbase/src/operations/durability_internal.h +199 -0
- data/ext/libcouchbase/src/operations/get.c +409 -0
- data/ext/libcouchbase/src/operations/observe-seqno.c +96 -0
- data/ext/libcouchbase/src/operations/observe.c +340 -0
- data/ext/libcouchbase/src/operations/pktfwd.c +86 -0
- data/ext/libcouchbase/src/operations/remove.c +83 -0
- data/ext/libcouchbase/src/operations/stats.c +461 -0
- data/ext/libcouchbase/src/operations/store.c +360 -0
- data/ext/libcouchbase/src/operations/subdoc.cc +510 -0
- data/ext/libcouchbase/src/operations/touch.c +81 -0
- data/ext/libcouchbase/src/packetutils.c +60 -0
- data/ext/libcouchbase/src/packetutils.h +147 -0
- data/ext/libcouchbase/src/probes.d +211 -0
- data/ext/libcouchbase/src/rdb/bigalloc.c +225 -0
- data/ext/libcouchbase/src/rdb/bigalloc.h +73 -0
- data/ext/libcouchbase/src/rdb/chunkalloc.c +174 -0
- data/ext/libcouchbase/src/rdb/libcalloc.c +94 -0
- data/ext/libcouchbase/src/rdb/rope.c +419 -0
- data/ext/libcouchbase/src/rdb/rope.h +488 -0
- data/ext/libcouchbase/src/retrychk.c +113 -0
- data/ext/libcouchbase/src/retryq.c +424 -0
- data/ext/libcouchbase/src/retryq.h +157 -0
- data/ext/libcouchbase/src/ringbuffer.c +442 -0
- data/ext/libcouchbase/src/ringbuffer.h +100 -0
- data/ext/libcouchbase/src/settings.c +95 -0
- data/ext/libcouchbase/src/settings.h +188 -0
- data/ext/libcouchbase/src/simplestring.c +211 -0
- data/ext/libcouchbase/src/simplestring.h +228 -0
- data/ext/libcouchbase/src/sllist-inl.h +197 -0
- data/ext/libcouchbase/src/sllist.h +76 -0
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +23 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +415 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +454 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +408 -0
- data/ext/libcouchbase/src/ssl/ssl_iot_common.h +180 -0
- data/ext/libcouchbase/src/ssobuf.h +82 -0
- data/ext/libcouchbase/src/strcodecs/base64.c +123 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +285 -0
- data/ext/libcouchbase/src/timings.c +208 -0
- data/ext/libcouchbase/src/trace.h +105 -0
- data/ext/libcouchbase/src/utilities.c +171 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -0
- data/ext/libcouchbase/src/vbucket/aliases.h +35 -0
- data/ext/libcouchbase/src/vbucket/crc32.h +83 -0
- data/ext/libcouchbase/src/vbucket/hash.h +30 -0
- data/ext/libcouchbase/src/vbucket/json-inl.h +112 -0
- data/ext/libcouchbase/src/vbucket/ketama.c +66 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/global.h +32 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5.h +35 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5c-inl.h +335 -0
- data/ext/libcouchbase/src/vbucket/vbucket.c +1543 -0
- data/ext/libcouchbase/src/views/docreq.c +194 -0
- data/ext/libcouchbase/src/views/docreq.h +83 -0
- data/ext/libcouchbase/src/views/viewreq.c +358 -0
- data/ext/libcouchbase/src/views/viewreq.h +36 -0
- data/ext/libcouchbase/src/wait.c +161 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +140 -0
- data/ext/libcouchbase/tests/basic/t_base64.cc +81 -0
- data/ext/libcouchbase/tests/basic/t_ccbc103.cc +95 -0
- data/ext/libcouchbase/tests/basic/t_connstr.cc +404 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +32 -0
- data/ext/libcouchbase/tests/basic/t_ctlcodes.cc +92 -0
- data/ext/libcouchbase/tests/basic/t_hashset.cc +262 -0
- data/ext/libcouchbase/tests/basic/t_host.cc +198 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +137 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.h +589 -0
- data/ext/libcouchbase/tests/basic/t_list.cc +155 -0
- data/ext/libcouchbase/tests/basic/t_logger.cc +65 -0
- data/ext/libcouchbase/tests/basic/t_misc.cc +24 -0
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +18 -0
- data/ext/libcouchbase/tests/basic/t_netbuf.cc +446 -0
- data/ext/libcouchbase/tests/basic/t_packet.cc +222 -0
- data/ext/libcouchbase/tests/basic/t_ringbuffer.cc +278 -0
- data/ext/libcouchbase/tests/basic/t_slist.cc +429 -0
- data/ext/libcouchbase/tests/basic/t_strerror.cc +64 -0
- data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
- data/ext/libcouchbase/tests/basic/t_urlencode.cc +132 -0
- data/ext/libcouchbase/tests/check-all.cc +608 -0
- data/ext/libcouchbase/tests/htparse/t_basic.cc +193 -0
- data/ext/libcouchbase/tests/ioserver/connection.cc +166 -0
- data/ext/libcouchbase/tests/ioserver/future.cc +50 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +104 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.h +478 -0
- data/ext/libcouchbase/tests/ioserver/socket.cc +88 -0
- data/ext/libcouchbase/tests/ioserver/ssl_connection.cc +145 -0
- data/ext/libcouchbase/tests/ioserver/threads-pthreads.cc +119 -0
- data/ext/libcouchbase/tests/ioserver/threads-win32.cc +117 -0
- data/ext/libcouchbase/tests/ioserver/threads.h +66 -0
- data/ext/libcouchbase/tests/iotests/iotests.h +15 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +524 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +385 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.cc +67 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.h +61 -0
- data/ext/libcouchbase/tests/iotests/serverparams.h +76 -0
- data/ext/libcouchbase/tests/iotests/t_arithmetic.cc +143 -0
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +226 -0
- data/ext/libcouchbase/tests/iotests/t_configcache.cc +117 -0
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +241 -0
- data/ext/libcouchbase/tests/iotests/t_durability.cc +1059 -0
- data/ext/libcouchbase/tests/iotests/t_forward.cc +110 -0
- data/ext/libcouchbase/tests/iotests/t_get.cc +512 -0
- data/ext/libcouchbase/tests/iotests/t_http.cc +438 -0
- data/ext/libcouchbase/tests/iotests/t_iops.cc +175 -0
- data/ext/libcouchbase/tests/iotests/t_lock.cc +275 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +713 -0
- data/ext/libcouchbase/tests/iotests/t_mutate.cc +609 -0
- data/ext/libcouchbase/tests/iotests/t_n1ql.cc +270 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +654 -0
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +157 -0
- data/ext/libcouchbase/tests/iotests/t_regression.cc +321 -0
- data/ext/libcouchbase/tests/iotests/t_sched.cc +88 -0
- data/ext/libcouchbase/tests/iotests/t_serverops.cc +230 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +528 -0
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +822 -0
- data/ext/libcouchbase/tests/iotests/t_syncmode.cc +64 -0
- data/ext/libcouchbase/tests/iotests/t_views.cc +405 -0
- data/ext/libcouchbase/tests/iotests/testutil.cc +250 -0
- data/ext/libcouchbase/tests/iotests/testutil.h +163 -0
- data/ext/libcouchbase/tests/mc/mctest.h +119 -0
- data/ext/libcouchbase/tests/mc/pktmaker.h +101 -0
- data/ext/libcouchbase/tests/mc/t_alloc.cc +269 -0
- data/ext/libcouchbase/tests/mc/t_context.cc +100 -0
- data/ext/libcouchbase/tests/mc/t_flush.cc +185 -0
- data/ext/libcouchbase/tests/mc/t_forward.cc +239 -0
- data/ext/libcouchbase/tests/mc/t_ioflush.cc +102 -0
- data/ext/libcouchbase/tests/mc/t_iovcursor.cc +173 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.c +305 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.h +89 -0
- data/ext/libcouchbase/tests/mocksupport/server.c +391 -0
- data/ext/libcouchbase/tests/mocksupport/server.h +72 -0
- data/ext/libcouchbase/tests/mocksupport/timeout.c +69 -0
- data/ext/libcouchbase/tests/nonio_tests.cc +23 -0
- data/ext/libcouchbase/tests/rdb/rdbtest.h +133 -0
- data/ext/libcouchbase/tests/rdb/t_basic.cc +128 -0
- data/ext/libcouchbase/tests/rdb/t_bigalloc.cc +93 -0
- data/ext/libcouchbase/tests/rdb/t_refs.cc +112 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +347 -0
- data/ext/libcouchbase/tests/socktests/socktest.h +448 -0
- data/ext/libcouchbase/tests/socktests/t_basic.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ctx.cc +73 -0
- data/ext/libcouchbase/tests/socktests/t_manager.cc +179 -0
- data/ext/libcouchbase/tests/socktests/t_putex.cc +256 -0
- data/ext/libcouchbase/tests/socktests/t_read.cc +187 -0
- data/ext/libcouchbase/tests/socktests/t_reentrant.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +80 -0
- data/ext/libcouchbase/tests/socktests/t_write.cc +95 -0
- data/ext/libcouchbase/tests/start_mock.bat +15 -0
- data/ext/libcouchbase/tests/start_mock.sh +42 -0
- data/ext/libcouchbase/tests/unit_tests.cc +43 -0
- data/ext/libcouchbase/tests/vbucket/confdata/bad.json +101 -0
- data/ext/libcouchbase/tests/vbucket/confdata/full_25.json +363 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_25.json +90 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_45.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_25.json +291 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +341 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +51 -0
- data/ext/libcouchbase/tools/cbc-handlers.h +462 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +439 -0
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +822 -0
- data/ext/libcouchbase/tools/cbc.cc +1541 -0
- data/ext/libcouchbase/tools/common/histogram.cc +43 -0
- data/ext/libcouchbase/tools/common/histogram.h +23 -0
- data/ext/libcouchbase/tools/common/my_inttypes.h +22 -0
- data/ext/libcouchbase/tools/common/options.cc +420 -0
- data/ext/libcouchbase/tools/common/options.h +81 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +469 -0
- data/ext/libcouchbase/tools/docgen/loc.h +210 -0
- data/ext/libcouchbase/tools/docgen/placeholders.h +211 -0
- data/ext/libcouchbase/tools/docgen/seqgen.h +94 -0
- data/lib/libcouchbase.rb +36 -0
- data/lib/libcouchbase/bucket.rb +819 -0
- data/lib/libcouchbase/callbacks.rb +72 -0
- data/lib/libcouchbase/connection.rb +790 -0
- data/lib/libcouchbase/design_docs.rb +86 -0
- data/lib/libcouchbase/error.rb +68 -0
- data/lib/libcouchbase/ext/libcouchbase.rb +1135 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdbase.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdcounter.rb +36 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdendure.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdfts.rb +24 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdget.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdgetreplica.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdhttp.rb +58 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdn1ql.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobseqno.rb +33 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobserve.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstore.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstoredur.rb +45 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdverbosity.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdviewquery.rb +61 -0
- data/lib/libcouchbase/ext/libcouchbase/contigbuf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st.rb +15 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st0.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st1.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st2.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st3.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/crst_u.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_st_v.rb +11 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_t.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/durabilityopt_sv0.rb +63 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +991 -0
- data/lib/libcouchbase/ext/libcouchbase/fragbuf.rb +18 -0
- data/lib/libcouchbase/ext/libcouchbase/ftshandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/histogram.rb +34 -0
- data/lib/libcouchbase/ext/libcouchbase/http_request_t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/keybuf.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/multicmd_ctx.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/mutation_token.rb +17 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlparams.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/respbase.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/respcounter.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respendure.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/respfts.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/respget.rb +44 -0
- data/lib/libcouchbase/ext/libcouchbase/resphttp.rb +48 -0
- data/lib/libcouchbase/ext/libcouchbase/respmcversion.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respn1ql.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respobseqno.rb +52 -0
- data/lib/libcouchbase/ext/libcouchbase/respobserve.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respserverbase.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstats.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respstore.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstoredur.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respsubdoc.rb +35 -0
- data/lib/libcouchbase/ext/libcouchbase/respviewquery.rb +67 -0
- data/lib/libcouchbase/ext/libcouchbase/sdentry.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf_u_buf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/viewhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase_iocp.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase_libuv.rb +18 -0
- data/lib/libcouchbase/ext/tasks.rb +87 -0
- data/lib/libcouchbase/n1ql.rb +73 -0
- data/lib/libcouchbase/query_full_text.rb +147 -0
- data/lib/libcouchbase/query_n1ql.rb +121 -0
- data/lib/libcouchbase/query_view.rb +129 -0
- data/lib/libcouchbase/results_fiber.rb +262 -0
- data/lib/libcouchbase/results_native.rb +211 -0
- data/lib/libcouchbase/version.rb +5 -0
- data/libcouchbase.gemspec +61 -0
- data/spec/bucket_spec.rb +270 -0
- data/spec/connection_spec.rb +277 -0
- data/spec/design_docs_spec.rb +23 -0
- data/spec/error_spec.rb +26 -0
- data/spec/fts_spec.rb +129 -0
- data/spec/n1ql_spec.rb +201 -0
- data/spec/results_libuv_spec.rb +229 -0
- data/spec/results_native_spec.rb +259 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/design.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/data-0000.cbb +0 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/failover.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/meta.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/seqno.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/snapshot_markers.json +1 -0
- data/spec/view_spec.rb +195 -0
- metadata +775 -0
@@ -0,0 +1,121 @@
|
|
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
|
+
#ifndef LCB_MCSERVER_H
|
19
|
+
#define LCB_MCSERVER_H
|
20
|
+
#include <libcouchbase/couchbase.h>
|
21
|
+
#include <lcbio/lcbio.h>
|
22
|
+
#include <lcbio/timer-ng.h>
|
23
|
+
#include <mc/mcreq.h>
|
24
|
+
#include <netbuf/netbuf.h>
|
25
|
+
|
26
|
+
#ifdef __cplusplus
|
27
|
+
extern "C" {
|
28
|
+
#endif
|
29
|
+
|
30
|
+
struct lcb_settings_st;
|
31
|
+
struct lcb_server_st;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* The structure representing each couchbase server
|
35
|
+
*/
|
36
|
+
typedef struct mc_SERVER_st {
|
37
|
+
/** Pipeline object for command queues */
|
38
|
+
mc_PIPELINE pipeline;
|
39
|
+
|
40
|
+
/** Pointer back to the instance */
|
41
|
+
lcb_t instance;
|
42
|
+
|
43
|
+
lcb_settings *settings;
|
44
|
+
|
45
|
+
/* Defined in mcserver.c */
|
46
|
+
int state;
|
47
|
+
|
48
|
+
/** Whether compression is supported */
|
49
|
+
short compsupport;
|
50
|
+
|
51
|
+
/** Whether extended 'UUID' and 'seqno' are available for each mutation */
|
52
|
+
short mutation_tokens;
|
53
|
+
|
54
|
+
/** IO/Operation timer */
|
55
|
+
lcbio_pTIMER io_timer;
|
56
|
+
|
57
|
+
lcbio_CTX *connctx;
|
58
|
+
lcbio_CONNREQ connreq;
|
59
|
+
|
60
|
+
/** Request for current connection */
|
61
|
+
lcb_host_t *curhost;
|
62
|
+
} mc_SERVER;
|
63
|
+
|
64
|
+
#define MCSERVER_TIMEOUT(c) (c)->settings->operation_timeout
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Allocate and initialize a new server object. The object will not be
|
68
|
+
* connected
|
69
|
+
* @param instance the instance to which the server belongs
|
70
|
+
* @param ix the server index in the configuration
|
71
|
+
* @return the new object or NULL on allocation failure.
|
72
|
+
*/
|
73
|
+
mc_SERVER *
|
74
|
+
mcserver_alloc(lcb_t instance, int ix);
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Close the server. The resources of the server may still continue to persist
|
78
|
+
* internally for a bit until all callbacks have been delivered and all buffers
|
79
|
+
* flushed and/or failed.
|
80
|
+
* @param server the server to release
|
81
|
+
*/
|
82
|
+
void
|
83
|
+
mcserver_close(mc_SERVER *server);
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Schedule a flush and potentially flush some immediate data on the server.
|
87
|
+
* This is safe to call multiple times, however performance considerations
|
88
|
+
* should be taken into account
|
89
|
+
*/
|
90
|
+
void
|
91
|
+
mcserver_flush(mc_SERVER *server);
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Wrapper around mcreq_pipeline_timeout() and/or mcreq_pipeline_fail(). This
|
95
|
+
* function will purge all pending requests within the server and invoke
|
96
|
+
* their callbacks with the given error code passed as `err`. Depending on
|
97
|
+
* the error code, some operations may be retried.
|
98
|
+
* @param server the server to fail
|
99
|
+
* @param err the error code by which to fail the commands
|
100
|
+
*
|
101
|
+
* @note This function does not modify the server's socket or state in itself,
|
102
|
+
* but rather simply wipes the commands from its queue
|
103
|
+
*/
|
104
|
+
void
|
105
|
+
mcserver_fail_chain(mc_SERVER *server, lcb_error_t err);
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Returns true or false depending on whether there are pending commands on
|
109
|
+
* this server
|
110
|
+
*/
|
111
|
+
LCB_INTERNAL_API
|
112
|
+
int
|
113
|
+
mcserver_has_pending(mc_SERVER *server);
|
114
|
+
|
115
|
+
#define mcserver_get_host(server) (server)->curhost->host
|
116
|
+
#define mcserver_get_port(server) (server)->curhost->port
|
117
|
+
|
118
|
+
#ifdef __cplusplus
|
119
|
+
}
|
120
|
+
#endif /* __cplusplus */
|
121
|
+
#endif /* LCB_MCSERVER_H */
|
@@ -0,0 +1,656 @@
|
|
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 "simplestring.h"
|
20
|
+
#include "mcserver.h"
|
21
|
+
#include "logging.h"
|
22
|
+
#include "settings.h"
|
23
|
+
#include <lcbio/lcbio.h>
|
24
|
+
#include <lcbio/timer-ng.h>
|
25
|
+
#include <lcbio/ssl.h>
|
26
|
+
#include <cbsasl/cbsasl.h>
|
27
|
+
#include "negotiate.h"
|
28
|
+
#include "ctx-log-inl.h"
|
29
|
+
|
30
|
+
#define LOGARGS(ctx, lvl) ctx->inner->settings, "negotiation", LCB_LOG_##lvl, __FILE__, __LINE__
|
31
|
+
static void cleanup_pending(mc_pSESSREQ);
|
32
|
+
static void cleanup_negotiated(mc_pSESSINFO);
|
33
|
+
static void bail_pending(mc_pSESSREQ sreq);
|
34
|
+
#define SESSREQ_LOGFMT "<%s:%s> (SASLREQ=%p) "
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Inner negotiation structure which is maintained as part of a 'protocol
|
38
|
+
* context'.
|
39
|
+
*/
|
40
|
+
struct mc_SESSINFO {
|
41
|
+
lcbio_PROTOCTX base;
|
42
|
+
cbsasl_conn_t *sasl;
|
43
|
+
char *mech;
|
44
|
+
unsigned int nmech;
|
45
|
+
lcb_settings *settings;
|
46
|
+
lcbio_CONNDONE_cb complete;
|
47
|
+
union {
|
48
|
+
cbsasl_secret_t secret;
|
49
|
+
char buffer[256];
|
50
|
+
} u_auth;
|
51
|
+
cbsasl_callback_t sasl_callbacks[4];
|
52
|
+
lcb_U16 features[MEMCACHED_TOTAL_HELLO_FEATURES+1];
|
53
|
+
};
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Structure used only for initialization. This is only used for the duration
|
57
|
+
* of the request for negotiation and is deleted once negotiation has
|
58
|
+
* completed (or failed).
|
59
|
+
*/
|
60
|
+
typedef struct mc_SESSREQ {
|
61
|
+
lcbio_CTX *ctx;
|
62
|
+
lcbio_CONNDONE_cb cb;
|
63
|
+
void *data;
|
64
|
+
lcbio_pTIMER timer;
|
65
|
+
lcb_error_t err;
|
66
|
+
mc_pSESSINFO inner;
|
67
|
+
} neg_PENDING;
|
68
|
+
|
69
|
+
#define SESSREQ_LOGID(s) get_ctx_host(s->ctx), get_ctx_port(s->ctx), (void*)s
|
70
|
+
|
71
|
+
static int
|
72
|
+
sasl_get_username(void *context, int id, const char **result, unsigned int *len)
|
73
|
+
{
|
74
|
+
struct mc_SESSINFO *ctx = context;
|
75
|
+
const char *u = NULL, *p = NULL;
|
76
|
+
if (!context || !result || (id != CBSASL_CB_USER && id != CBSASL_CB_AUTHNAME)) {
|
77
|
+
return SASL_BADPARAM;
|
78
|
+
}
|
79
|
+
|
80
|
+
lcbauth_get_upass(ctx->settings->auth, &u, &p);
|
81
|
+
*result = u;
|
82
|
+
if (len) {
|
83
|
+
*len = (unsigned int)strlen(*result);
|
84
|
+
}
|
85
|
+
|
86
|
+
return SASL_OK;
|
87
|
+
}
|
88
|
+
|
89
|
+
static int
|
90
|
+
sasl_get_password(cbsasl_conn_t *conn, void *context, int id,
|
91
|
+
cbsasl_secret_t **psecret)
|
92
|
+
{
|
93
|
+
struct mc_SESSINFO *ctx = context;
|
94
|
+
if (!conn || ! psecret || id != CBSASL_CB_PASS || ctx == NULL) {
|
95
|
+
return SASL_BADPARAM;
|
96
|
+
}
|
97
|
+
|
98
|
+
*psecret = &ctx->u_auth.secret;
|
99
|
+
return SASL_OK;
|
100
|
+
}
|
101
|
+
|
102
|
+
static lcb_error_t
|
103
|
+
setup_sasl_params(struct mc_SESSINFO *ctx)
|
104
|
+
{
|
105
|
+
int ii;
|
106
|
+
cbsasl_callback_t *callbacks = ctx->sasl_callbacks;
|
107
|
+
const char *pass = NULL, *user = NULL;
|
108
|
+
|
109
|
+
callbacks[0].id = CBSASL_CB_USER;
|
110
|
+
callbacks[0].proc = (int( *)(void)) &sasl_get_username;
|
111
|
+
|
112
|
+
callbacks[1].id = CBSASL_CB_AUTHNAME;
|
113
|
+
callbacks[1].proc = (int( *)(void)) &sasl_get_username;
|
114
|
+
|
115
|
+
callbacks[2].id = CBSASL_CB_PASS;
|
116
|
+
callbacks[2].proc = (int( *)(void)) &sasl_get_password;
|
117
|
+
|
118
|
+
callbacks[3].id = CBSASL_CB_LIST_END;
|
119
|
+
callbacks[3].proc = NULL;
|
120
|
+
callbacks[3].context = NULL;
|
121
|
+
|
122
|
+
for (ii = 0; ii < 3; ii++) {
|
123
|
+
callbacks[ii].context = ctx;
|
124
|
+
}
|
125
|
+
|
126
|
+
memset(&ctx->u_auth, 0, sizeof(ctx->u_auth));
|
127
|
+
lcbauth_get_upass(ctx->settings->auth, &user, &pass);
|
128
|
+
|
129
|
+
if (pass) {
|
130
|
+
unsigned long pwlen;
|
131
|
+
lcb_size_t maxlen;
|
132
|
+
|
133
|
+
pwlen = (unsigned long)strlen(pass);
|
134
|
+
maxlen = sizeof(ctx->u_auth.buffer) - offsetof(cbsasl_secret_t, data);
|
135
|
+
ctx->u_auth.secret.len = pwlen;
|
136
|
+
|
137
|
+
if (pwlen < maxlen) {
|
138
|
+
memcpy(ctx->u_auth.secret.data, pass, pwlen);
|
139
|
+
} else {
|
140
|
+
return LCB_EINVAL;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
return LCB_SUCCESS;
|
144
|
+
}
|
145
|
+
|
146
|
+
static void
|
147
|
+
close_cb(lcbio_SOCKET *s, int reusable, void *arg)
|
148
|
+
{
|
149
|
+
*(lcbio_SOCKET **)arg = s;
|
150
|
+
lcbio_ref(s);
|
151
|
+
lcb_assert(reusable);
|
152
|
+
}
|
153
|
+
|
154
|
+
static void
|
155
|
+
negotiation_success(mc_pSESSREQ sreq)
|
156
|
+
{
|
157
|
+
/** Dislodge the connection, and return it back to the caller */
|
158
|
+
lcbio_SOCKET *s;
|
159
|
+
|
160
|
+
lcbio_ctx_close(sreq->ctx, close_cb, &s);
|
161
|
+
sreq->ctx = NULL;
|
162
|
+
|
163
|
+
lcbio_protoctx_add(s, &sreq->inner->base);
|
164
|
+
sreq->inner = NULL;
|
165
|
+
|
166
|
+
/** Invoke the callback, marking it a success */
|
167
|
+
sreq->cb(s, sreq->data, LCB_SUCCESS, 0);
|
168
|
+
lcbio_unref(s);
|
169
|
+
cleanup_pending(sreq);
|
170
|
+
}
|
171
|
+
|
172
|
+
static void
|
173
|
+
bail_pending(mc_pSESSREQ sreq)
|
174
|
+
{
|
175
|
+
sreq->cb(NULL, sreq->data, sreq->err, 0);
|
176
|
+
cleanup_pending(sreq);
|
177
|
+
}
|
178
|
+
|
179
|
+
static void
|
180
|
+
set_error_ex(mc_pSESSREQ sreq, lcb_error_t err, const char *msg)
|
181
|
+
{
|
182
|
+
lcb_log(LOGARGS(sreq, ERR), SESSREQ_LOGFMT "Error: 0x%x, %s", SESSREQ_LOGID(sreq), err, msg);
|
183
|
+
if (sreq->err == LCB_SUCCESS) {
|
184
|
+
sreq->err = err;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
static void
|
189
|
+
timeout_handler(void *arg)
|
190
|
+
{
|
191
|
+
mc_pSESSREQ sreq = arg;
|
192
|
+
set_error_ex(sreq, LCB_ETIMEDOUT, "Negotiation timed out");
|
193
|
+
bail_pending(sreq);
|
194
|
+
}
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Called to retrive the mechlist from the packet.
|
198
|
+
* @return 0 to continue authentication, 1 if no authentication needed, or
|
199
|
+
* -1 on error.
|
200
|
+
*/
|
201
|
+
static int
|
202
|
+
set_chosen_mech(mc_pSESSREQ sreq, lcb_string *mechlist, const char **data,
|
203
|
+
unsigned int *ndata)
|
204
|
+
{
|
205
|
+
cbsasl_error_t saslerr;
|
206
|
+
const char *chosenmech;
|
207
|
+
mc_pSESSINFO ctx = sreq->inner;
|
208
|
+
|
209
|
+
lcb_assert(sreq->inner);
|
210
|
+
if (ctx->settings->sasl_mech_force) {
|
211
|
+
char *forcemech = ctx->settings->sasl_mech_force;
|
212
|
+
if (!strstr(mechlist->base, forcemech)) {
|
213
|
+
/** Requested mechanism not found */
|
214
|
+
set_error_ex(sreq, LCB_SASLMECH_UNAVAILABLE, mechlist->base);
|
215
|
+
return -1;
|
216
|
+
}
|
217
|
+
|
218
|
+
lcb_string_clear(mechlist);
|
219
|
+
if (lcb_string_appendz(mechlist, forcemech)) {
|
220
|
+
set_error_ex(sreq, LCB_CLIENT_ENOMEM, NULL);
|
221
|
+
return -1;
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
saslerr = cbsasl_client_start(ctx->sasl, mechlist->base,
|
226
|
+
NULL, data, ndata, &chosenmech);
|
227
|
+
switch (saslerr) {
|
228
|
+
case SASL_OK:
|
229
|
+
ctx->nmech = strlen(chosenmech);
|
230
|
+
if (! (ctx->mech = strdup(chosenmech)) ) {
|
231
|
+
set_error_ex(sreq, LCB_CLIENT_ENOMEM, NULL);
|
232
|
+
return -1;
|
233
|
+
}
|
234
|
+
return 0;
|
235
|
+
case SASL_NOMECH:
|
236
|
+
lcb_log(LOGARGS(sreq, INFO), SESSREQ_LOGFMT "Server does not support SASL (no mechanisms supported)", SESSREQ_LOGID(sreq));
|
237
|
+
return 1;
|
238
|
+
break;
|
239
|
+
default:
|
240
|
+
lcb_log(LOGARGS(sreq, INFO), SESSREQ_LOGFMT "cbsasl_client_start returned %d", SESSREQ_LOGID(sreq), saslerr);
|
241
|
+
set_error_ex(sreq, LCB_EINTERNAL, "Couldn't start SASL client");
|
242
|
+
return -1;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
/**
|
247
|
+
* Given the specific mechanisms, send the auth packet to the server.
|
248
|
+
*/
|
249
|
+
static int
|
250
|
+
send_sasl_auth(neg_PENDING *pend, const char *sasl_data, unsigned ndata)
|
251
|
+
{
|
252
|
+
mc_pSESSINFO ctx = pend->inner;
|
253
|
+
protocol_binary_request_no_extras req;
|
254
|
+
protocol_binary_request_header *hdr = &req.message.header;
|
255
|
+
memset(&req, 0, sizeof(req));
|
256
|
+
|
257
|
+
hdr->request.magic = PROTOCOL_BINARY_REQ;
|
258
|
+
hdr->request.opcode = PROTOCOL_BINARY_CMD_SASL_AUTH;
|
259
|
+
hdr->request.keylen = htons((lcb_uint16_t)ctx->nmech);
|
260
|
+
hdr->request.datatype = PROTOCOL_BINARY_RAW_BYTES;
|
261
|
+
hdr->request.bodylen = htonl((lcb_uint32_t)ndata + ctx->nmech);
|
262
|
+
|
263
|
+
lcbio_ctx_put(pend->ctx, req.bytes, sizeof(req.bytes));
|
264
|
+
lcbio_ctx_put(pend->ctx, ctx->mech, ctx->nmech);
|
265
|
+
lcbio_ctx_put(pend->ctx, sasl_data, ndata);
|
266
|
+
lcbio_ctx_rwant(pend->ctx, 24);
|
267
|
+
return 0;
|
268
|
+
}
|
269
|
+
|
270
|
+
static int
|
271
|
+
send_sasl_step(mc_pSESSREQ sreq, packet_info *packet)
|
272
|
+
{
|
273
|
+
protocol_binary_request_no_extras req;
|
274
|
+
protocol_binary_request_header *hdr = &req.message.header;
|
275
|
+
cbsasl_error_t saslerr;
|
276
|
+
const char *step_data;
|
277
|
+
unsigned int ndata;
|
278
|
+
mc_pSESSINFO ctx = sreq->inner;
|
279
|
+
|
280
|
+
saslerr = cbsasl_client_step(
|
281
|
+
ctx->sasl, packet->payload, PACKET_NBODY(packet), NULL, &step_data,
|
282
|
+
&ndata);
|
283
|
+
|
284
|
+
if (saslerr != SASL_CONTINUE) {
|
285
|
+
set_error_ex(sreq, LCB_EINTERNAL, "Unable to perform SASL STEP");
|
286
|
+
return -1;
|
287
|
+
}
|
288
|
+
|
289
|
+
memset(&req, 0, sizeof(req));
|
290
|
+
hdr->request.magic = PROTOCOL_BINARY_REQ;
|
291
|
+
hdr->request.opcode = PROTOCOL_BINARY_CMD_SASL_STEP;
|
292
|
+
hdr->request.keylen = htons((uint16_t)ctx->nmech);
|
293
|
+
hdr->request.bodylen = htonl((uint32_t)ndata + ctx->nmech);
|
294
|
+
hdr->request.datatype = PROTOCOL_BINARY_RAW_BYTES;
|
295
|
+
|
296
|
+
lcbio_ctx_put(sreq->ctx, req.bytes, sizeof(req.bytes));
|
297
|
+
lcbio_ctx_put(sreq->ctx, ctx->mech, ctx->nmech);
|
298
|
+
lcbio_ctx_put(sreq->ctx, step_data, ndata);
|
299
|
+
lcbio_ctx_rwant(sreq->ctx, 24);
|
300
|
+
return 0;
|
301
|
+
}
|
302
|
+
|
303
|
+
static int
|
304
|
+
send_hello(mc_pSESSREQ sreq)
|
305
|
+
{
|
306
|
+
protocol_binary_request_no_extras req;
|
307
|
+
protocol_binary_request_header *hdr = &req.message.header;
|
308
|
+
unsigned ii;
|
309
|
+
const char *external_id = "";
|
310
|
+
const char *comma = "";
|
311
|
+
char client_id[200] = { 0 };
|
312
|
+
lcb_U16 features[MEMCACHED_TOTAL_HELLO_FEATURES];
|
313
|
+
unsigned nfeatures = 0;
|
314
|
+
size_t nclistr;
|
315
|
+
|
316
|
+
features[nfeatures++] = PROTOCOL_BINARY_FEATURE_TLS;
|
317
|
+
if (sreq->inner->settings->tcp_nodelay) {
|
318
|
+
features[nfeatures++] = PROTOCOL_BINARY_FEATURE_TCPNODELAY;
|
319
|
+
}
|
320
|
+
|
321
|
+
#ifndef LCB_NO_SNAPPY
|
322
|
+
if (sreq->inner->settings->compressopts != LCB_COMPRESS_NONE) {
|
323
|
+
features[nfeatures++] = PROTOCOL_BINARY_FEATURE_DATATYPE;
|
324
|
+
}
|
325
|
+
#endif
|
326
|
+
|
327
|
+
if (sreq->inner->settings->fetch_mutation_tokens) {
|
328
|
+
features[nfeatures++] = PROTOCOL_BINARY_FEATURE_MUTATION_SEQNO;
|
329
|
+
}
|
330
|
+
|
331
|
+
if (sreq->inner->settings->client_string) {
|
332
|
+
external_id = sreq->inner->settings->client_string;
|
333
|
+
comma = ", ";
|
334
|
+
}
|
335
|
+
|
336
|
+
snprintf(client_id, 199, "libcouchbase/%s%s%s",
|
337
|
+
LCB_VERSION_STRING, comma, external_id);
|
338
|
+
nclistr = strlen(client_id);
|
339
|
+
|
340
|
+
memset(&req, 0, sizeof req);
|
341
|
+
hdr->request.opcode = PROTOCOL_BINARY_CMD_HELLO;
|
342
|
+
hdr->request.magic = PROTOCOL_BINARY_REQ;
|
343
|
+
hdr->request.keylen = htons((lcb_U16)nclistr);
|
344
|
+
hdr->request.bodylen = htonl((lcb_U32)(nclistr+ (sizeof features[0]) * nfeatures));
|
345
|
+
hdr->request.datatype = PROTOCOL_BINARY_RAW_BYTES;
|
346
|
+
|
347
|
+
lcbio_ctx_put(sreq->ctx, req.bytes, sizeof req.bytes);
|
348
|
+
lcbio_ctx_put(sreq->ctx, client_id, strlen(client_id));
|
349
|
+
for (ii = 0; ii < nfeatures; ii++) {
|
350
|
+
lcb_U16 tmp = htons(features[ii]);
|
351
|
+
lcbio_ctx_put(sreq->ctx, &tmp, sizeof tmp);
|
352
|
+
}
|
353
|
+
lcbio_ctx_rwant(sreq->ctx, 24);
|
354
|
+
return 0;
|
355
|
+
}
|
356
|
+
|
357
|
+
static int
|
358
|
+
parse_hello(mc_pSESSREQ sreq, packet_info *packet)
|
359
|
+
{
|
360
|
+
/* some caps */
|
361
|
+
const char *cur;
|
362
|
+
const char *payload = PACKET_BODY(packet);
|
363
|
+
const char *limit = payload + PACKET_NBODY(packet);
|
364
|
+
for (cur = payload; cur < limit; cur += 2) {
|
365
|
+
lcb_U16 tmp;
|
366
|
+
memcpy(&tmp, cur, sizeof(tmp));
|
367
|
+
tmp = ntohs(tmp);
|
368
|
+
lcb_log(LOGARGS(sreq, DEBUG), SESSREQ_LOGFMT "Found feature 0x%x (%s)", SESSREQ_LOGID(sreq), tmp, protocol_feature_2_text(tmp));
|
369
|
+
sreq->inner->features[tmp] = 1;
|
370
|
+
}
|
371
|
+
return 0;
|
372
|
+
}
|
373
|
+
|
374
|
+
|
375
|
+
typedef enum {
|
376
|
+
SREQ_S_WAIT,
|
377
|
+
SREQ_S_AUTHDONE,
|
378
|
+
SREQ_S_HELLODONE,
|
379
|
+
SREQ_S_ERROR
|
380
|
+
} sreq_STATE;
|
381
|
+
|
382
|
+
/**
|
383
|
+
* It's assumed the server buffers will be reset upon close(), so we must make
|
384
|
+
* sure to _not_ release the ringbuffer if that happens.
|
385
|
+
*/
|
386
|
+
static void
|
387
|
+
handle_read(lcbio_CTX *ioctx, unsigned nb)
|
388
|
+
{
|
389
|
+
mc_pSESSREQ sreq = lcbio_ctx_data(ioctx);
|
390
|
+
packet_info info;
|
391
|
+
unsigned required;
|
392
|
+
uint16_t status;
|
393
|
+
sreq_STATE state = SREQ_S_WAIT;
|
394
|
+
int rc;
|
395
|
+
|
396
|
+
GT_NEXT_PACKET:
|
397
|
+
|
398
|
+
memset(&info, 0, sizeof(info));
|
399
|
+
rc = lcb_pktinfo_ectx_get(&info, ioctx, &required);
|
400
|
+
if (rc == 0) {
|
401
|
+
LCBIO_CTX_RSCHEDULE(ioctx, required);
|
402
|
+
return;
|
403
|
+
} else if (rc < 0) {
|
404
|
+
state = SREQ_S_ERROR;
|
405
|
+
}
|
406
|
+
|
407
|
+
status = PACKET_STATUS(&info);
|
408
|
+
|
409
|
+
switch (PACKET_OPCODE(&info)) {
|
410
|
+
case PROTOCOL_BINARY_CMD_SASL_LIST_MECHS: {
|
411
|
+
lcb_string str;
|
412
|
+
int saslrc;
|
413
|
+
const char *mechlist_data;
|
414
|
+
unsigned int nmechlist_data;
|
415
|
+
if (lcb_string_init(&str)) {
|
416
|
+
set_error_ex(sreq, LCB_CLIENT_ENOMEM, NULL);
|
417
|
+
state = SREQ_S_ERROR;
|
418
|
+
break;
|
419
|
+
}
|
420
|
+
|
421
|
+
if (lcb_string_append(&str, info.payload, PACKET_NBODY(&info))) {
|
422
|
+
lcb_string_release(&str);
|
423
|
+
set_error_ex(sreq, LCB_CLIENT_ENOMEM, NULL);
|
424
|
+
state = SREQ_S_ERROR;
|
425
|
+
break;
|
426
|
+
}
|
427
|
+
|
428
|
+
saslrc = set_chosen_mech(sreq, &str, &mechlist_data, &nmechlist_data);
|
429
|
+
if (saslrc == 0) {
|
430
|
+
if (0 == send_sasl_auth(sreq, mechlist_data, nmechlist_data)) {
|
431
|
+
state = SREQ_S_WAIT;
|
432
|
+
} else {
|
433
|
+
state = SREQ_S_ERROR;
|
434
|
+
}
|
435
|
+
|
436
|
+
} else if (saslrc < 0) {
|
437
|
+
state = SREQ_S_ERROR;
|
438
|
+
|
439
|
+
} else {
|
440
|
+
state = SREQ_S_HELLODONE;
|
441
|
+
}
|
442
|
+
lcb_string_release(&str);
|
443
|
+
break;
|
444
|
+
}
|
445
|
+
|
446
|
+
case PROTOCOL_BINARY_CMD_SASL_AUTH: {
|
447
|
+
if (status == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
|
448
|
+
send_hello(sreq);
|
449
|
+
state = SREQ_S_AUTHDONE;
|
450
|
+
break;
|
451
|
+
}
|
452
|
+
|
453
|
+
if (status != PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE) {
|
454
|
+
set_error_ex(sreq, LCB_AUTH_ERROR, "SASL AUTH failed");
|
455
|
+
state = SREQ_S_ERROR;
|
456
|
+
break;
|
457
|
+
}
|
458
|
+
if (send_sasl_step(sreq, &info) == 0 && send_hello(sreq) == 0) {
|
459
|
+
state = SREQ_S_WAIT;
|
460
|
+
} else {
|
461
|
+
state = SREQ_S_ERROR;
|
462
|
+
}
|
463
|
+
break;
|
464
|
+
}
|
465
|
+
|
466
|
+
case PROTOCOL_BINARY_CMD_SASL_STEP: {
|
467
|
+
if (status != PROTOCOL_BINARY_RESPONSE_SUCCESS) {
|
468
|
+
lcb_log(LOGARGS(sreq, WARN), SESSREQ_LOGFMT "SASL auth failed with STATUS=0x%x", SESSREQ_LOGID(sreq), status);
|
469
|
+
set_error_ex(sreq, LCB_AUTH_ERROR, "SASL Step Failed");
|
470
|
+
state = SREQ_S_ERROR;
|
471
|
+
} else {
|
472
|
+
/* Wait for pipelined HELLO response */
|
473
|
+
state = SREQ_S_AUTHDONE;
|
474
|
+
}
|
475
|
+
break;
|
476
|
+
}
|
477
|
+
|
478
|
+
case PROTOCOL_BINARY_CMD_HELLO: {
|
479
|
+
state = SREQ_S_HELLODONE;
|
480
|
+
if (status == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
|
481
|
+
parse_hello(sreq, &info);
|
482
|
+
} else if (status == PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND ||
|
483
|
+
status == PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED) {
|
484
|
+
lcb_log(LOGARGS(sreq, DEBUG), SESSREQ_LOGFMT "Server does not support HELLO", SESSREQ_LOGID(sreq));
|
485
|
+
/* nothing */
|
486
|
+
} else {
|
487
|
+
set_error_ex(sreq, LCB_PROTOCOL_ERROR, "Hello response unexpected");
|
488
|
+
state = SREQ_S_ERROR;
|
489
|
+
}
|
490
|
+
break;
|
491
|
+
}
|
492
|
+
|
493
|
+
default: {
|
494
|
+
state = SREQ_S_ERROR;
|
495
|
+
lcb_log(LOGARGS(sreq, ERROR), SESSREQ_LOGFMT "Received unknown response. OP=0x%x. RC=0x%x", SESSREQ_LOGID(sreq), PACKET_OPCODE(&info), PACKET_STATUS(&info));
|
496
|
+
set_error_ex(sreq, LCB_NOT_SUPPORTED, "Received unknown response");
|
497
|
+
break;
|
498
|
+
}
|
499
|
+
}
|
500
|
+
|
501
|
+
lcb_pktinfo_ectx_done(&info, ioctx);
|
502
|
+
if (sreq->err != LCB_SUCCESS) {
|
503
|
+
bail_pending(sreq);
|
504
|
+
} else if (state == SREQ_S_ERROR) {
|
505
|
+
set_error_ex(sreq, LCB_ERROR, "FIXME: Error code set without description");
|
506
|
+
} else if (state == SREQ_S_HELLODONE) {
|
507
|
+
negotiation_success(sreq);
|
508
|
+
} else {
|
509
|
+
goto GT_NEXT_PACKET;
|
510
|
+
}
|
511
|
+
|
512
|
+
(void)nb;
|
513
|
+
}
|
514
|
+
|
515
|
+
static void
|
516
|
+
handle_ioerr(lcbio_CTX *ctx, lcb_error_t err)
|
517
|
+
{
|
518
|
+
mc_pSESSREQ sreq = lcbio_ctx_data(ctx);
|
519
|
+
set_error_ex(sreq, err, "IO Error");
|
520
|
+
bail_pending(sreq);
|
521
|
+
}
|
522
|
+
|
523
|
+
static void
|
524
|
+
cleanup_negotiated(mc_pSESSINFO ctx)
|
525
|
+
{
|
526
|
+
if (ctx->sasl) {
|
527
|
+
cbsasl_dispose(&ctx->sasl);
|
528
|
+
}
|
529
|
+
if (ctx->mech) {
|
530
|
+
free(ctx->mech);
|
531
|
+
}
|
532
|
+
free(ctx);
|
533
|
+
}
|
534
|
+
|
535
|
+
static void
|
536
|
+
cleanup_pending(mc_pSESSREQ sreq)
|
537
|
+
{
|
538
|
+
if (sreq->inner) {
|
539
|
+
cleanup_negotiated(sreq->inner);
|
540
|
+
sreq->inner = NULL;
|
541
|
+
}
|
542
|
+
if (sreq->timer) {
|
543
|
+
lcbio_timer_destroy(sreq->timer);
|
544
|
+
sreq->timer = NULL;
|
545
|
+
}
|
546
|
+
if (sreq->ctx) {
|
547
|
+
lcbio_ctx_close(sreq->ctx, NULL, NULL);
|
548
|
+
sreq->ctx = NULL;
|
549
|
+
}
|
550
|
+
free(sreq);
|
551
|
+
}
|
552
|
+
|
553
|
+
void
|
554
|
+
mc_sessreq_cancel(mc_pSESSREQ sreq)
|
555
|
+
{
|
556
|
+
cleanup_pending(sreq);
|
557
|
+
}
|
558
|
+
|
559
|
+
mc_pSESSREQ
|
560
|
+
mc_sessreq_start(lcbio_SOCKET *sock, lcb_settings *settings,
|
561
|
+
uint32_t tmo, lcbio_CONNDONE_cb callback, void *data)
|
562
|
+
{
|
563
|
+
lcb_error_t err;
|
564
|
+
cbsasl_error_t saslerr;
|
565
|
+
protocol_binary_request_no_extras req;
|
566
|
+
const lcb_host_t *curhost;
|
567
|
+
struct lcbio_NAMEINFO nistrs;
|
568
|
+
mc_pSESSREQ sreq;
|
569
|
+
mc_pSESSINFO sasl;
|
570
|
+
lcbio_CTXPROCS procs;
|
571
|
+
|
572
|
+
if ((sreq = calloc(1, sizeof(*sreq))) == NULL) {
|
573
|
+
return NULL;
|
574
|
+
}
|
575
|
+
|
576
|
+
if ((sasl = calloc(1, sizeof(*sasl))) == NULL) {
|
577
|
+
cleanup_pending(sreq);
|
578
|
+
return NULL;
|
579
|
+
}
|
580
|
+
|
581
|
+
procs.cb_err = handle_ioerr;
|
582
|
+
procs.cb_read = handle_read;
|
583
|
+
|
584
|
+
lcbio_get_nameinfo(sock, &nistrs);
|
585
|
+
sreq->cb = callback;
|
586
|
+
sreq->data = data;
|
587
|
+
sreq->inner = sasl;
|
588
|
+
sreq->timer = lcbio_timer_new(sock->io, sreq, timeout_handler);
|
589
|
+
|
590
|
+
if ((err = lcbio_sslify_if_needed(sock, settings)) != LCB_SUCCESS) {
|
591
|
+
set_error_ex(sreq, err, "Couldn't initialize SSL on socket");
|
592
|
+
lcbio_async_signal(sreq->timer);
|
593
|
+
return sreq;
|
594
|
+
}
|
595
|
+
|
596
|
+
sreq->ctx = lcbio_ctx_new(sock, sreq, &procs);
|
597
|
+
sreq->ctx->subsys = "sasl";
|
598
|
+
|
599
|
+
if (tmo) {
|
600
|
+
lcbio_timer_rearm(sreq->timer, tmo);
|
601
|
+
}
|
602
|
+
|
603
|
+
sasl->base.id = LCBIO_PROTOCTX_SESSINFO;
|
604
|
+
sasl->base.dtor = (void (*)(struct lcbio_PROTOCTX *))cleanup_negotiated;
|
605
|
+
sasl->settings = settings;
|
606
|
+
|
607
|
+
err = setup_sasl_params(sasl);
|
608
|
+
if (err != LCB_SUCCESS) {
|
609
|
+
cleanup_pending(sreq);
|
610
|
+
return NULL;
|
611
|
+
}
|
612
|
+
|
613
|
+
|
614
|
+
curhost = lcbio_get_host(sock);
|
615
|
+
saslerr = cbsasl_client_new(
|
616
|
+
"couchbase", curhost->host, nistrs.local, nistrs.remote,
|
617
|
+
sasl->sasl_callbacks, 0, &sasl->sasl);
|
618
|
+
|
619
|
+
if (saslerr != SASL_OK) {
|
620
|
+
cleanup_pending(sreq);
|
621
|
+
return NULL;
|
622
|
+
}
|
623
|
+
|
624
|
+
memset(&req, 0, sizeof(req));
|
625
|
+
req.message.header.request.magic = PROTOCOL_BINARY_REQ;
|
626
|
+
req.message.header.request.opcode = PROTOCOL_BINARY_CMD_SASL_LIST_MECHS;
|
627
|
+
req.message.header.request.datatype = PROTOCOL_BINARY_RAW_BYTES;
|
628
|
+
req.message.header.request.bodylen = 0;
|
629
|
+
req.message.header.request.keylen = 0;
|
630
|
+
req.message.header.request.opaque = 0;
|
631
|
+
|
632
|
+
lcbio_ctx_put(sreq->ctx, req.bytes, sizeof(req.bytes));
|
633
|
+
LCBIO_CTX_RSCHEDULE(sreq->ctx, 24);
|
634
|
+
return sreq;
|
635
|
+
}
|
636
|
+
|
637
|
+
mc_pSESSINFO
|
638
|
+
mc_sess_get(lcbio_SOCKET *sock)
|
639
|
+
{
|
640
|
+
return (void *)lcbio_protoctx_get(sock, LCBIO_PROTOCTX_SESSINFO);
|
641
|
+
}
|
642
|
+
|
643
|
+
const char *
|
644
|
+
mc_sess_get_saslmech(mc_pSESSINFO info)
|
645
|
+
{
|
646
|
+
return info->mech;
|
647
|
+
}
|
648
|
+
|
649
|
+
int
|
650
|
+
mc_sess_chkfeature(mc_pSESSINFO info, lcb_U16 feature)
|
651
|
+
{
|
652
|
+
if (feature > MEMCACHED_TOTAL_HELLO_FEATURES) {
|
653
|
+
return 0;
|
654
|
+
}
|
655
|
+
return info->features[feature];
|
656
|
+
}
|