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,34 @@
|
|
1
|
+
#ifndef LCB_HTTPAPI_H
|
2
|
+
#define LCB_HTTPAPI_H
|
3
|
+
|
4
|
+
/* This file contains the internal API for HTTP requests. This allows us to
|
5
|
+
* change the internals without exposing the object structure to the rest
|
6
|
+
* of the library
|
7
|
+
*/
|
8
|
+
|
9
|
+
#ifdef __cplusplus
|
10
|
+
extern "C" {
|
11
|
+
#endif
|
12
|
+
|
13
|
+
void
|
14
|
+
lcb_htreq_setcb(lcb_http_request_t, lcb_RESPCALLBACK);
|
15
|
+
|
16
|
+
void
|
17
|
+
lcb_htreq_pause(lcb_http_request_t);
|
18
|
+
|
19
|
+
void
|
20
|
+
lcb_htreq_resume(lcb_http_request_t);
|
21
|
+
|
22
|
+
void
|
23
|
+
lcb_htreq_finish(lcb_t, lcb_http_request_t, lcb_error_t);
|
24
|
+
|
25
|
+
/* Prevents the callback from being invoked. This is different than a full
|
26
|
+
* destruction of the object. This is only called in lcb_destroy() to
|
27
|
+
* prevent dereferencing the instance itself.
|
28
|
+
*/
|
29
|
+
void
|
30
|
+
lcb_htreq_block_callback(lcb_http_request_t);
|
31
|
+
#ifdef __cplusplus
|
32
|
+
}
|
33
|
+
#endif
|
34
|
+
#endif
|
@@ -0,0 +1,307 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2013 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
|
+
#include "internal.h"
|
18
|
+
#include "logging.h"
|
19
|
+
#include "settings.h"
|
20
|
+
#include "http-priv.h"
|
21
|
+
#include "http.h"
|
22
|
+
#include "ctx-log-inl.h"
|
23
|
+
#include "sllist.h"
|
24
|
+
#include <lcbio/ssl.h>
|
25
|
+
|
26
|
+
using namespace lcb::http;
|
27
|
+
|
28
|
+
#define LOGFMT "<%s:%s>"
|
29
|
+
#define LOGID(req) get_ctx_host((req)->ioctx), get_ctx_port((req)->ioctx)
|
30
|
+
#define LOGARGS(req, lvl) req->instance->settings, "http-io", LCB_LOG_##lvl, __FILE__, __LINE__
|
31
|
+
|
32
|
+
void
|
33
|
+
Request::assign_response_headers(const lcbht_RESPONSE *resp)
|
34
|
+
{
|
35
|
+
response_headers.clear();
|
36
|
+
response_headers_clist.clear();
|
37
|
+
|
38
|
+
sllist_node *curnode;
|
39
|
+
SLLIST_ITERBASIC(&resp->headers, curnode) {
|
40
|
+
lcbht_MIMEHDR *hdr = SLLIST_ITEM(curnode, lcbht_MIMEHDR, slnode);
|
41
|
+
response_headers.push_back(Header(hdr->key, hdr->value));
|
42
|
+
}
|
43
|
+
|
44
|
+
std::vector<Header>::const_iterator ii = response_headers.begin();
|
45
|
+
for (; ii != response_headers.end(); ++ii) {
|
46
|
+
response_headers_clist.push_back(ii->key.c_str());
|
47
|
+
response_headers_clist.push_back(ii->value.c_str());
|
48
|
+
}
|
49
|
+
response_headers_clist.push_back(NULL);
|
50
|
+
}
|
51
|
+
|
52
|
+
int
|
53
|
+
Request::handle_parse_chunked(const char *buf, unsigned nbuf)
|
54
|
+
{
|
55
|
+
int parse_state, oldstate, diff;
|
56
|
+
lcbht_RESPONSE *res = lcbht_get_response(parser);
|
57
|
+
|
58
|
+
do {
|
59
|
+
const char *rbody;
|
60
|
+
unsigned nused = -1, nbody = -1;
|
61
|
+
oldstate = res->state;
|
62
|
+
|
63
|
+
parse_state = lcbht_parse_ex(parser, buf, nbuf, &nused, &nbody, &rbody);
|
64
|
+
diff = oldstate ^ parse_state;
|
65
|
+
|
66
|
+
/* Got headers now for the first time */
|
67
|
+
if (diff & LCBHT_S_HEADER) {
|
68
|
+
assign_response_headers(res);
|
69
|
+
if (res->status >= 300 && res->status <= 400) {
|
70
|
+
const char *redir = lcbht_get_resphdr(res, "Location");
|
71
|
+
if (redir != NULL) {
|
72
|
+
pending_redirect.assign(redir);
|
73
|
+
return LCBHT_S_DONE;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
if (parse_state & LCBHT_S_ERROR) {
|
79
|
+
/* nothing to do here */
|
80
|
+
return parse_state;
|
81
|
+
}
|
82
|
+
|
83
|
+
if (nbody) {
|
84
|
+
if (chunked) {
|
85
|
+
lcb_RESPHTTP htresp = { 0 };
|
86
|
+
init_resp(&htresp);
|
87
|
+
htresp.body = rbody;
|
88
|
+
htresp.nbody = nbody;
|
89
|
+
htresp.rc = LCB_SUCCESS;
|
90
|
+
passed_data = true;
|
91
|
+
callback(instance, LCB_CALLBACK_HTTP, (const lcb_RESPBASE *)&htresp);
|
92
|
+
|
93
|
+
} else {
|
94
|
+
lcb_string_append(&res->body, rbody, nbody);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
buf += nused;
|
99
|
+
nbuf -= nused;
|
100
|
+
} while ((parse_state & LCBHT_S_DONE) == 0 && is_ongoing() && nbuf);
|
101
|
+
|
102
|
+
if ( (parse_state & LCBHT_S_DONE) && is_ongoing()) {
|
103
|
+
lcb_RESPHTTP resp = { 0 };
|
104
|
+
if (chunked) {
|
105
|
+
buf = NULL;
|
106
|
+
nbuf = 0;
|
107
|
+
} else {
|
108
|
+
buf = res->body.base;
|
109
|
+
nbuf = res->body.nused;
|
110
|
+
}
|
111
|
+
|
112
|
+
init_resp(&resp);
|
113
|
+
resp.rflags = LCB_RESP_F_FINAL;
|
114
|
+
resp.rc = LCB_SUCCESS;
|
115
|
+
resp.body = buf;
|
116
|
+
resp.nbody = nbuf;
|
117
|
+
passed_data = true;
|
118
|
+
callback(instance, LCB_CALLBACK_HTTP, (const lcb_RESPBASE*)&resp);
|
119
|
+
status |= Request::CBINVOKED;
|
120
|
+
}
|
121
|
+
return parse_state;
|
122
|
+
}
|
123
|
+
|
124
|
+
static void
|
125
|
+
io_read(lcbio_CTX *ctx, unsigned nr)
|
126
|
+
{
|
127
|
+
Request *req = reinterpret_cast<Request*>(lcbio_ctx_data(ctx));
|
128
|
+
lcb_t instance = req->instance;
|
129
|
+
/** this variable set to 0 (in progress), -1 (error), 1 (done) */
|
130
|
+
int rv = 0;
|
131
|
+
lcbio_CTXRDITER iter;
|
132
|
+
req->incref();
|
133
|
+
|
134
|
+
/** Delay the timer */
|
135
|
+
lcbio_timer_rearm(req->timer, req->timeout());
|
136
|
+
|
137
|
+
LCBIO_CTX_ITERFOR(ctx, &iter, nr) {
|
138
|
+
char *buf;
|
139
|
+
unsigned nbuf;
|
140
|
+
int parse_state;
|
141
|
+
|
142
|
+
buf = reinterpret_cast<char*>(lcbio_ctx_ribuf(&iter));
|
143
|
+
nbuf = lcbio_ctx_risize(&iter);
|
144
|
+
parse_state = req->handle_parse_chunked(buf, nbuf);
|
145
|
+
|
146
|
+
if ((parse_state & LCBHT_S_ERROR) || req->has_pending_redirect()) {
|
147
|
+
rv = -1;
|
148
|
+
break;
|
149
|
+
} else if (!req->is_ongoing()) {
|
150
|
+
rv = 1;
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
if (rv == -1) {
|
156
|
+
// parse error or redirect
|
157
|
+
lcb_error_t err;
|
158
|
+
if (req->has_pending_redirect()) {
|
159
|
+
lcb_bootstrap_common(instance, LCB_BS_REFRESH_THROTTLE);
|
160
|
+
// Transfer control to redirect function()
|
161
|
+
lcb_log(LOGARGS(req, DEBUG), LOGFMT "Attempting redirect to %s", LOGID(req), req->pending_redirect.c_str());
|
162
|
+
req->redirect();
|
163
|
+
} else {
|
164
|
+
err = LCB_PROTOCOL_ERROR;
|
165
|
+
lcb_log(LOGARGS(req, ERR), LOGFMT "Got parser error while parsing HTTP stream", LOGID(req));
|
166
|
+
req->finish_or_retry(err);
|
167
|
+
}
|
168
|
+
} else if (rv == 1) {
|
169
|
+
// Complete
|
170
|
+
req->finish(LCB_SUCCESS);
|
171
|
+
} else {
|
172
|
+
// Pending
|
173
|
+
lcbio_ctx_rwant(ctx, req->paused ? 0 : 1);
|
174
|
+
lcbio_ctx_schedule(ctx);
|
175
|
+
}
|
176
|
+
|
177
|
+
req->decref();
|
178
|
+
}
|
179
|
+
|
180
|
+
void
|
181
|
+
Request::pause()
|
182
|
+
{
|
183
|
+
if (!paused) {
|
184
|
+
paused = true;
|
185
|
+
if (ioctx) {
|
186
|
+
lcbio_ctx_rwant(ioctx, 0);
|
187
|
+
lcbio_ctx_schedule(ioctx);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
void
|
193
|
+
Request::resume()
|
194
|
+
{
|
195
|
+
if (!paused) {
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
|
199
|
+
if (ioctx == NULL) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
paused = false;
|
203
|
+
lcbio_ctx_rwant(ioctx, 1);
|
204
|
+
lcbio_ctx_schedule(ioctx);
|
205
|
+
}
|
206
|
+
|
207
|
+
static void
|
208
|
+
io_error(lcbio_CTX *ctx, lcb_error_t err)
|
209
|
+
{
|
210
|
+
Request *req = reinterpret_cast<Request*>(lcbio_ctx_data(ctx));
|
211
|
+
lcb_log(LOGARGS(req, ERR), LOGFMT "Got error while performing I/O on HTTP stream. Err=0x%x", LOGID(req), err);
|
212
|
+
req->finish_or_retry(err);
|
213
|
+
}
|
214
|
+
|
215
|
+
static void
|
216
|
+
request_timed_out(void *arg)
|
217
|
+
{
|
218
|
+
(reinterpret_cast<Request*>(arg))->finish(LCB_ETIMEDOUT);
|
219
|
+
}
|
220
|
+
|
221
|
+
static void
|
222
|
+
on_connected(lcbio_SOCKET *sock, void *arg, lcb_error_t err, lcbio_OSERR syserr)
|
223
|
+
{
|
224
|
+
Request *req = reinterpret_cast<Request*>(arg);
|
225
|
+
lcbio_CTXPROCS procs;
|
226
|
+
lcb_settings *settings = req->instance->settings;
|
227
|
+
|
228
|
+
LCBIO_CONNREQ_CLEAR(&req->creq);
|
229
|
+
|
230
|
+
if (err != LCB_SUCCESS) {
|
231
|
+
lcb_log(LOGARGS(req, ERR), "Connection to failed with Err=0x%x", err);
|
232
|
+
req->finish_or_retry(err);
|
233
|
+
return;
|
234
|
+
}
|
235
|
+
|
236
|
+
lcbio_sslify_if_needed(sock, settings);
|
237
|
+
|
238
|
+
procs.cb_err = io_error;
|
239
|
+
procs.cb_read = io_read;
|
240
|
+
req->ioctx = lcbio_ctx_new(sock, arg, &procs);
|
241
|
+
req->ioctx->subsys = "mgmt/capi";
|
242
|
+
lcbio_ctx_put(req->ioctx, &req->preamble[0], req->preamble.size());
|
243
|
+
if (!req->body.empty()) {
|
244
|
+
lcbio_ctx_put(req->ioctx, &req->body[0], req->body.size());
|
245
|
+
}
|
246
|
+
lcbio_ctx_rwant(req->ioctx, 1);
|
247
|
+
lcbio_ctx_schedule(req->ioctx);
|
248
|
+
(void)syserr;
|
249
|
+
}
|
250
|
+
|
251
|
+
lcb_error_t
|
252
|
+
Request::start_io(lcb_host_t& dest)
|
253
|
+
{
|
254
|
+
lcbio_MGR *pool = instance->http_sockpool;
|
255
|
+
lcbio_pMGRREQ poolreq;
|
256
|
+
|
257
|
+
poolreq = lcbio_mgr_get(pool, &dest, timeout(), on_connected, this);
|
258
|
+
if (!poolreq) {
|
259
|
+
return LCB_CONNECT_ERROR;
|
260
|
+
}
|
261
|
+
|
262
|
+
LCBIO_CONNREQ_MKPOOLED(&creq, poolreq);
|
263
|
+
|
264
|
+
if (!timer) {
|
265
|
+
timer = lcbio_timer_new(io, this, request_timed_out);
|
266
|
+
}
|
267
|
+
|
268
|
+
if (!lcbio_timer_armed(timer)) {
|
269
|
+
lcbio_timer_rearm(timer, timeout());
|
270
|
+
}
|
271
|
+
|
272
|
+
return LCB_SUCCESS;
|
273
|
+
}
|
274
|
+
|
275
|
+
static void
|
276
|
+
pool_close_cb(lcbio_SOCKET *sock, int reusable, void *arg)
|
277
|
+
{
|
278
|
+
int close_ok = *(int *)arg;
|
279
|
+
|
280
|
+
lcbio_ref(sock);
|
281
|
+
if (reusable && close_ok) {
|
282
|
+
lcbio_mgr_put(sock);
|
283
|
+
} else {
|
284
|
+
lcbio_mgr_discard(sock);
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
288
|
+
void
|
289
|
+
Request::close_io()
|
290
|
+
{
|
291
|
+
lcbio_connreq_cancel(&creq);
|
292
|
+
|
293
|
+
if (!ioctx) {
|
294
|
+
return;
|
295
|
+
}
|
296
|
+
|
297
|
+
int can_ka;
|
298
|
+
|
299
|
+
if (parser && is_data_request()) {
|
300
|
+
can_ka = lcbht_can_keepalive(parser);
|
301
|
+
} else {
|
302
|
+
can_ka = 0;
|
303
|
+
}
|
304
|
+
|
305
|
+
lcbio_ctx_close(ioctx, pool_close_cb, &can_ka);
|
306
|
+
ioctx = NULL;
|
307
|
+
}
|
@@ -0,0 +1,722 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2010-2013 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
|
+
#include "internal.h"
|
18
|
+
#include "connspec.h"
|
19
|
+
#include "logging.h"
|
20
|
+
#include "hostlist.h"
|
21
|
+
#include "http/http.h"
|
22
|
+
#include "bucketconfig/clconfig.h"
|
23
|
+
#include <lcbio/iotable.h>
|
24
|
+
#include <lcbio/ssl.h>
|
25
|
+
#define LOGARGS(obj,lvl) (obj)->settings, "instance", LCB_LOG_##lvl, __FILE__, __LINE__
|
26
|
+
|
27
|
+
static volatile unsigned int lcb_instance_index = 0;
|
28
|
+
using namespace lcb;
|
29
|
+
|
30
|
+
LIBCOUCHBASE_API
|
31
|
+
const char *lcb_get_version(lcb_uint32_t *version)
|
32
|
+
{
|
33
|
+
if (version != NULL) {
|
34
|
+
*version = (lcb_uint32_t)LCB_VERSION;
|
35
|
+
}
|
36
|
+
|
37
|
+
return LCB_VERSION_STRING;
|
38
|
+
}
|
39
|
+
|
40
|
+
const lcb_U32 lcb_version_g = LCB_VERSION;
|
41
|
+
|
42
|
+
LIBCOUCHBASE_API
|
43
|
+
void lcb_set_cookie(lcb_t instance, const void *cookie)
|
44
|
+
{
|
45
|
+
instance->cookie = cookie;
|
46
|
+
}
|
47
|
+
|
48
|
+
LIBCOUCHBASE_API
|
49
|
+
const void *lcb_get_cookie(lcb_t instance)
|
50
|
+
{
|
51
|
+
return instance->cookie;
|
52
|
+
}
|
53
|
+
|
54
|
+
void
|
55
|
+
lcb_st::add_bs_host(const char *host, int port, unsigned bstype)
|
56
|
+
{
|
57
|
+
const char *tname = NULL;
|
58
|
+
lcb::Hostlist* target;
|
59
|
+
if (bstype == LCB_CONFIG_TRANSPORT_CCCP) {
|
60
|
+
tname = "CCCP";
|
61
|
+
target = mc_nodes;
|
62
|
+
} else {
|
63
|
+
tname = "HTTP";
|
64
|
+
target = ht_nodes;
|
65
|
+
}
|
66
|
+
lcb_log(LOGARGS(this, DEBUG), "Adding host %s:%d to initial %s bootstrap list", host, port, tname);
|
67
|
+
target->add(host, port);
|
68
|
+
}
|
69
|
+
|
70
|
+
void
|
71
|
+
lcb_st::add_bs_host(const lcb::Spechost& host, int defl_http, int defl_cccp)
|
72
|
+
{
|
73
|
+
if (host.isTypeless()) {
|
74
|
+
add_bs_host(host.hostname.c_str(), defl_http, LCB_CONFIG_TRANSPORT_HTTP);
|
75
|
+
add_bs_host(host.hostname.c_str(), defl_cccp, LCB_CONFIG_TRANSPORT_CCCP);
|
76
|
+
return;
|
77
|
+
} else {
|
78
|
+
add_bs_host(host.hostname.c_str(), host.port,
|
79
|
+
host.isAnyHttp()
|
80
|
+
? LCB_CONFIG_TRANSPORT_HTTP : LCB_CONFIG_TRANSPORT_CCCP);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
void
|
85
|
+
lcb_st::populate_nodes(const Connspec& spec)
|
86
|
+
{
|
87
|
+
int has_ssl = settings->sslopts & LCB_SSL_ENABLED;
|
88
|
+
int defl_http, defl_cccp;
|
89
|
+
|
90
|
+
if (spec.default_port() == LCB_CONFIG_MCCOMPAT_PORT) {
|
91
|
+
defl_http = -1;
|
92
|
+
defl_cccp = LCB_CONFIG_MCCOMPAT_PORT;
|
93
|
+
|
94
|
+
} else if (has_ssl) {
|
95
|
+
defl_http = LCB_CONFIG_HTTP_SSL_PORT;
|
96
|
+
defl_cccp = LCB_CONFIG_MCD_SSL_PORT;
|
97
|
+
} else {
|
98
|
+
defl_http = LCB_CONFIG_HTTP_PORT;
|
99
|
+
defl_cccp = LCB_CONFIG_MCD_PORT;
|
100
|
+
}
|
101
|
+
|
102
|
+
for (size_t ii = 0; ii < spec.hosts().size(); ++ii) {
|
103
|
+
const Spechost &dh = spec.hosts()[ii];
|
104
|
+
add_bs_host(dh, defl_http, defl_cccp);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
static lcb_error_t
|
109
|
+
init_providers(lcb_t obj, const Connspec &spec)
|
110
|
+
{
|
111
|
+
clconfig_provider *http, *cccp, *mcraw;
|
112
|
+
http = lcb_confmon_get_provider(obj->confmon, LCB_CLCONFIG_HTTP);
|
113
|
+
cccp = lcb_confmon_get_provider(obj->confmon, LCB_CLCONFIG_CCCP);
|
114
|
+
mcraw = lcb_confmon_get_provider(obj->confmon, LCB_CLCONFIG_MCRAW);
|
115
|
+
|
116
|
+
if (spec.default_port() == LCB_CONFIG_MCCOMPAT_PORT) {
|
117
|
+
lcb_confmon_set_provider_active(obj->confmon, LCB_CLCONFIG_MCRAW, 1);
|
118
|
+
mcraw->configure_nodes(mcraw, obj->mc_nodes);
|
119
|
+
return LCB_SUCCESS;
|
120
|
+
}
|
121
|
+
|
122
|
+
bool cccp_found = spec.is_bs_cccp();
|
123
|
+
bool http_found = spec.is_bs_http();
|
124
|
+
bool cccp_enabled = true, http_enabled = true;
|
125
|
+
|
126
|
+
if (cccp_found || http_found || spec.is_bs_file()) {
|
127
|
+
http_enabled = http_found;
|
128
|
+
cccp_enabled = cccp_found;
|
129
|
+
|
130
|
+
}
|
131
|
+
|
132
|
+
if (lcb_getenv_boolean("LCB_NO_CCCP")) {
|
133
|
+
cccp_enabled = false;
|
134
|
+
}
|
135
|
+
if (lcb_getenv_boolean("LCB_NO_HTTP")) {
|
136
|
+
http_enabled = false;
|
137
|
+
}
|
138
|
+
if (spec.is_bs_file()) {
|
139
|
+
cccp_found = false;
|
140
|
+
http_found = false;
|
141
|
+
}
|
142
|
+
|
143
|
+
if (cccp_enabled == 0 && http_enabled == 0) {
|
144
|
+
if (spec.is_bs_file()) {
|
145
|
+
/* If the 'file_only' provider is set, just assume something else
|
146
|
+
* will provide us with the config, and forget about it. */
|
147
|
+
clconfig_provider *prov = lcb_confmon_get_provider(obj->confmon, LCB_CLCONFIG_FILE);
|
148
|
+
if (prov && prov->enabled) {
|
149
|
+
return LCB_SUCCESS;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
return LCB_BAD_ENVIRONMENT;
|
153
|
+
}
|
154
|
+
|
155
|
+
if (http_enabled) {
|
156
|
+
lcb_clconfig_http_enable(http);
|
157
|
+
lcb_clconfig_http_set_nodes(http, obj->ht_nodes);
|
158
|
+
} else {
|
159
|
+
lcb_confmon_set_provider_active(obj->confmon, LCB_CLCONFIG_HTTP, 0);
|
160
|
+
}
|
161
|
+
|
162
|
+
if (cccp_enabled && obj->type != LCB_TYPE_CLUSTER) {
|
163
|
+
lcb_clconfig_cccp_enable(cccp, obj);
|
164
|
+
lcb_clconfig_cccp_set_nodes(cccp, obj->mc_nodes);
|
165
|
+
} else {
|
166
|
+
lcb_confmon_set_provider_active(obj->confmon, LCB_CLCONFIG_CCCP, 0);
|
167
|
+
}
|
168
|
+
return LCB_SUCCESS;
|
169
|
+
}
|
170
|
+
|
171
|
+
static lcb_error_t
|
172
|
+
setup_ssl(lcb_t obj, const Connspec& params)
|
173
|
+
{
|
174
|
+
char optbuf[4096];
|
175
|
+
int env_policy = -1;
|
176
|
+
lcb_settings *settings = obj->settings;
|
177
|
+
lcb_error_t err = LCB_SUCCESS;
|
178
|
+
|
179
|
+
if (lcb_getenv_nonempty("LCB_SSL_CACERT", optbuf, sizeof optbuf)) {
|
180
|
+
lcb_log(LOGARGS(obj, INFO), "SSL CA certificate %s specified on environment", optbuf);
|
181
|
+
settings->certpath = strdup(optbuf);
|
182
|
+
}
|
183
|
+
|
184
|
+
if (lcb_getenv_nonempty("LCB_SSL_MODE", optbuf, sizeof optbuf)) {
|
185
|
+
if (sscanf(optbuf, "%d", &env_policy) != 1) {
|
186
|
+
lcb_log(LOGARGS(obj, ERR), "Invalid value for environment LCB_SSL. (%s)", optbuf);
|
187
|
+
return LCB_BAD_ENVIRONMENT;
|
188
|
+
} else {
|
189
|
+
lcb_log(LOGARGS(obj, INFO), "SSL modified from environment. Policy is 0x%x", env_policy);
|
190
|
+
settings->sslopts = env_policy;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
if (settings->certpath == NULL && !params.certpath().empty()) {
|
195
|
+
settings->certpath = strdup(params.certpath().c_str());
|
196
|
+
}
|
197
|
+
|
198
|
+
if (env_policy == -1) {
|
199
|
+
settings->sslopts = params.sslopts();
|
200
|
+
}
|
201
|
+
|
202
|
+
if (settings->sslopts & LCB_SSL_ENABLED) {
|
203
|
+
if (! (settings->sslopts & LCB_SSL_NOGLOBALINIT)) {
|
204
|
+
lcbio_ssl_global_init();
|
205
|
+
} else {
|
206
|
+
lcb_log(LOGARGS(obj, INFO), "ssl=no_global_init. Not initializing openssl globals");
|
207
|
+
}
|
208
|
+
settings->ssl_ctx = lcbio_ssl_new(settings->certpath,
|
209
|
+
settings->sslopts & LCB_SSL_NOVERIFY, &err, settings);
|
210
|
+
if (!settings->ssl_ctx) {
|
211
|
+
return err;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
return LCB_SUCCESS;
|
215
|
+
}
|
216
|
+
|
217
|
+
static lcb_error_t
|
218
|
+
apply_spec_options(lcb_t obj, const Connspec& params)
|
219
|
+
{
|
220
|
+
lcb_error_t err;
|
221
|
+
Connspec::Options::const_iterator ii = params.options().begin();
|
222
|
+
for (; ii != params.options().end(); ++ii) {
|
223
|
+
lcb_log(LOGARGS(obj, DEBUG), "Applying initial cntl %s=%s",
|
224
|
+
ii->first.c_str(), ii->second.c_str());
|
225
|
+
|
226
|
+
err = lcb_cntl_string(obj, ii->first.c_str(), ii->second.c_str());
|
227
|
+
if (err != LCB_SUCCESS) {
|
228
|
+
return err;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
return LCB_SUCCESS;
|
232
|
+
}
|
233
|
+
|
234
|
+
static lcb_error_t
|
235
|
+
apply_env_options(lcb_t obj)
|
236
|
+
{
|
237
|
+
Connspec tmpspec;
|
238
|
+
const char *options = getenv("LCB_OPTIONS");
|
239
|
+
|
240
|
+
if (!options) {
|
241
|
+
return LCB_SUCCESS;
|
242
|
+
}
|
243
|
+
|
244
|
+
std::string tmp("couchbase://?");
|
245
|
+
tmp.append(options);
|
246
|
+
if (tmpspec.parse(tmp.c_str()) != LCB_SUCCESS) {
|
247
|
+
return LCB_BAD_ENVIRONMENT;
|
248
|
+
}
|
249
|
+
return apply_spec_options(obj, tmpspec);
|
250
|
+
}
|
251
|
+
|
252
|
+
lcb_error_t
|
253
|
+
lcb_init_providers2(lcb_t obj, const struct lcb_create_st2 *options)
|
254
|
+
{
|
255
|
+
Connspec params;
|
256
|
+
lcb_error_t err;
|
257
|
+
struct lcb_create_st cropts;
|
258
|
+
cropts.version = 2;
|
259
|
+
cropts.v.v2 = *options;
|
260
|
+
err = params.load(cropts);
|
261
|
+
if (err == LCB_SUCCESS) {
|
262
|
+
err = init_providers(obj, params);
|
263
|
+
}
|
264
|
+
return err;
|
265
|
+
}
|
266
|
+
|
267
|
+
lcb_error_t
|
268
|
+
lcb_reinit3(lcb_t obj, const char *connstr)
|
269
|
+
{
|
270
|
+
Connspec params;
|
271
|
+
lcb_error_t err;
|
272
|
+
const char *errmsg = NULL;
|
273
|
+
memset(¶ms, 0, sizeof params);
|
274
|
+
err = params.parse(connstr, &errmsg);
|
275
|
+
|
276
|
+
if (err != LCB_SUCCESS) {
|
277
|
+
lcb_log(LOGARGS(obj, ERROR), "Couldn't reinit: %s", errmsg);
|
278
|
+
}
|
279
|
+
|
280
|
+
if (params.sslopts() != LCBT_SETTING(obj, sslopts) ||
|
281
|
+
!params.certpath().empty()) {
|
282
|
+
lcb_log(LOGARGS(obj, WARN), "Ignoring SSL reinit options");
|
283
|
+
}
|
284
|
+
|
285
|
+
/* apply the options */
|
286
|
+
err = apply_spec_options(obj, params);
|
287
|
+
if (err != LCB_SUCCESS) {
|
288
|
+
goto GT_DONE;
|
289
|
+
}
|
290
|
+
obj->populate_nodes(params);
|
291
|
+
err = init_providers(obj, params);
|
292
|
+
if (err != LCB_SUCCESS) {
|
293
|
+
goto GT_DONE;
|
294
|
+
}
|
295
|
+
|
296
|
+
GT_DONE:
|
297
|
+
return err;
|
298
|
+
}
|
299
|
+
|
300
|
+
LIBCOUCHBASE_API
|
301
|
+
lcb_error_t lcb_create(lcb_t *instance,
|
302
|
+
const struct lcb_create_st *options)
|
303
|
+
{
|
304
|
+
Connspec spec;
|
305
|
+
struct lcb_io_opt_st *io_priv = NULL;
|
306
|
+
lcb_type_t type = LCB_TYPE_BUCKET;
|
307
|
+
lcb_t obj = NULL;
|
308
|
+
lcb_error_t err;
|
309
|
+
lcb_settings *settings;
|
310
|
+
|
311
|
+
if (options) {
|
312
|
+
io_priv = options->v.v0.io;
|
313
|
+
if (options->version > 0) {
|
314
|
+
type = options->v.v1.type;
|
315
|
+
}
|
316
|
+
err = spec.load(*options);
|
317
|
+
} else {
|
318
|
+
const char *errmsg;
|
319
|
+
err = spec.parse("couchbase://", &errmsg);
|
320
|
+
}
|
321
|
+
if (err != LCB_SUCCESS) {
|
322
|
+
goto GT_DONE;
|
323
|
+
}
|
324
|
+
|
325
|
+
if ((obj = (lcb_t)calloc(1, sizeof(*obj))) == NULL) {
|
326
|
+
err = LCB_CLIENT_ENOMEM;
|
327
|
+
goto GT_DONE;
|
328
|
+
}
|
329
|
+
if (!(settings = lcb_settings_new())) {
|
330
|
+
err = LCB_CLIENT_ENOMEM;
|
331
|
+
goto GT_DONE;
|
332
|
+
}
|
333
|
+
|
334
|
+
/* initialize the settings */
|
335
|
+
obj->type = type;
|
336
|
+
obj->settings = settings;
|
337
|
+
|
338
|
+
settings->bucket = strdup(spec.bucket().c_str());
|
339
|
+
if ((err = settings->auth->init(spec.username(), spec.bucket(),
|
340
|
+
spec.password(), type)) != LCB_SUCCESS) {
|
341
|
+
goto GT_DONE;
|
342
|
+
}
|
343
|
+
|
344
|
+
settings->logger = lcb_init_console_logger();
|
345
|
+
settings->iid = lcb_instance_index++;
|
346
|
+
if (spec.loglevel()) {
|
347
|
+
lcb_U32 val = spec.loglevel();
|
348
|
+
lcb_cntl(obj, LCB_CNTL_SET, LCB_CNTL_CONLOGGER_LEVEL, &val);
|
349
|
+
}
|
350
|
+
|
351
|
+
lcb_log(LOGARGS(obj, INFO), "Version=%s, Changeset=%s", lcb_get_version(NULL), LCB_VERSION_CHANGESET);
|
352
|
+
lcb_log(LOGARGS(obj, INFO), "Effective connection string: %s. Bucket=%s", spec.connstr().c_str(), settings->bucket);
|
353
|
+
|
354
|
+
if (io_priv == NULL) {
|
355
|
+
lcb_io_opt_t ops;
|
356
|
+
if ((err = lcb_create_io_ops(&ops, NULL)) != LCB_SUCCESS) {
|
357
|
+
goto GT_DONE;
|
358
|
+
}
|
359
|
+
io_priv = ops;
|
360
|
+
LCB_IOPS_BASEFLD(io_priv, need_cleanup) = 1;
|
361
|
+
}
|
362
|
+
|
363
|
+
obj->cmdq.cqdata = obj;
|
364
|
+
obj->iotable = lcbio_table_new(io_priv);
|
365
|
+
obj->memd_sockpool = lcbio_mgr_create(settings, obj->iotable);
|
366
|
+
obj->http_sockpool = lcbio_mgr_create(settings, obj->iotable);
|
367
|
+
obj->memd_sockpool->maxidle = 1;
|
368
|
+
obj->memd_sockpool->tmoidle = 10000000;
|
369
|
+
obj->http_sockpool->maxidle = 1;
|
370
|
+
obj->http_sockpool->tmoidle = 10000000;
|
371
|
+
obj->confmon = lcb_confmon_create(settings, obj->iotable);
|
372
|
+
obj->ht_nodes = hostlist_create();
|
373
|
+
obj->mc_nodes = hostlist_create();
|
374
|
+
obj->retryq = lcb_retryq_new(&obj->cmdq, obj->iotable, obj->settings);
|
375
|
+
obj->n1ql_cache = lcb_n1qlcache_create();
|
376
|
+
lcb_initialize_packet_handlers(obj);
|
377
|
+
lcb_aspend_init(&obj->pendops);
|
378
|
+
|
379
|
+
if ((err = setup_ssl(obj, spec)) != LCB_SUCCESS) {
|
380
|
+
goto GT_DONE;
|
381
|
+
}
|
382
|
+
|
383
|
+
if ((err = apply_spec_options(obj, spec)) != LCB_SUCCESS) {
|
384
|
+
goto GT_DONE;
|
385
|
+
}
|
386
|
+
if ((err = apply_env_options(obj)) != LCB_SUCCESS) {
|
387
|
+
goto GT_DONE;
|
388
|
+
}
|
389
|
+
|
390
|
+
obj->populate_nodes(spec);
|
391
|
+
err = init_providers(obj, spec);
|
392
|
+
if (err != LCB_SUCCESS) {
|
393
|
+
lcb_destroy(obj);
|
394
|
+
return err;
|
395
|
+
}
|
396
|
+
|
397
|
+
obj->last_error = err;
|
398
|
+
GT_DONE:
|
399
|
+
if (err != LCB_SUCCESS && obj) {
|
400
|
+
lcb_destroy(obj);
|
401
|
+
*instance = NULL;
|
402
|
+
} else {
|
403
|
+
*instance = obj;
|
404
|
+
}
|
405
|
+
return err;
|
406
|
+
}
|
407
|
+
|
408
|
+
typedef struct {
|
409
|
+
lcbio_pTABLE table;
|
410
|
+
lcbio_pTIMER timer;
|
411
|
+
int stopped;
|
412
|
+
} SYNCDTOR;
|
413
|
+
|
414
|
+
static void
|
415
|
+
sync_dtor_cb(void *arg)
|
416
|
+
{
|
417
|
+
SYNCDTOR *sd = (SYNCDTOR*)arg;
|
418
|
+
if (sd->table->refcount == 2) {
|
419
|
+
lcbio_timer_destroy(sd->timer);
|
420
|
+
IOT_STOP(sd->table);
|
421
|
+
sd->stopped = 1;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
|
425
|
+
LIBCOUCHBASE_API
|
426
|
+
void lcb_destroy(lcb_t instance)
|
427
|
+
{
|
428
|
+
#define DESTROY(fn,fld) if(instance->fld){fn(instance->fld);instance->fld=NULL;}
|
429
|
+
|
430
|
+
lcb_size_t ii;
|
431
|
+
hashset_t hs;
|
432
|
+
lcb_ASPEND *po = &instance->pendops;
|
433
|
+
|
434
|
+
DESTROY(lcb_clconfig_decref, cur_configinfo);
|
435
|
+
instance->cmdq.config = NULL;
|
436
|
+
|
437
|
+
lcb_bootstrap_destroy(instance);
|
438
|
+
DESTROY(hostlist_destroy, ht_nodes);
|
439
|
+
DESTROY(hostlist_destroy, mc_nodes);
|
440
|
+
if ((hs = lcb_aspend_get(po, LCB_PENDTYPE_TIMER))) {
|
441
|
+
for (ii = 0; ii < hs->capacity; ++ii) {
|
442
|
+
if (hs->items[ii] > 1) {
|
443
|
+
lcb__timer_destroy_nowarn(instance, (lcb_timer_t)hs->items[ii]);
|
444
|
+
}
|
445
|
+
}
|
446
|
+
}
|
447
|
+
|
448
|
+
if ((hs = lcb_aspend_get(po, LCB_PENDTYPE_DURABILITY))) {
|
449
|
+
struct lcb_DURSET_st **dset_list;
|
450
|
+
lcb_size_t nitems = hashset_num_items(hs);
|
451
|
+
dset_list = (struct lcb_DURSET_st **)hashset_get_items(hs, NULL);
|
452
|
+
if (dset_list) {
|
453
|
+
for (ii = 0; ii < nitems; ii++) {
|
454
|
+
lcbdur_destroy(dset_list[ii]);
|
455
|
+
}
|
456
|
+
free(dset_list);
|
457
|
+
}
|
458
|
+
}
|
459
|
+
|
460
|
+
for (ii = 0; ii < LCBT_NSERVERS(instance); ++ii) {
|
461
|
+
mc_SERVER *server = LCBT_GET_SERVER(instance, ii);
|
462
|
+
mcserver_close(server);
|
463
|
+
}
|
464
|
+
|
465
|
+
if ((hs = lcb_aspend_get(po, LCB_PENDTYPE_HTTP))) {
|
466
|
+
for (ii = 0; ii < hs->capacity; ++ii) {
|
467
|
+
if (hs->items[ii] > 1) {
|
468
|
+
lcb_http_request_t htreq = (lcb_http_request_t)hs->items[ii];
|
469
|
+
|
470
|
+
/* Prevents lcb's globals from being modified during destruction */
|
471
|
+
lcb_htreq_block_callback(htreq);
|
472
|
+
lcb_htreq_finish(instance, htreq, LCB_ERROR);
|
473
|
+
}
|
474
|
+
}
|
475
|
+
}
|
476
|
+
DESTROY(lcb_retryq_destroy, retryq);
|
477
|
+
DESTROY(lcb_confmon_destroy, confmon);
|
478
|
+
DESTROY(lcbio_mgr_destroy, memd_sockpool);
|
479
|
+
DESTROY(lcbio_mgr_destroy, http_sockpool);
|
480
|
+
DESTROY(lcb_vbguess_destroy, vbguess);
|
481
|
+
DESTROY(lcb_n1qlcache_destroy, n1ql_cache);
|
482
|
+
|
483
|
+
mcreq_queue_cleanup(&instance->cmdq);
|
484
|
+
lcb_aspend_cleanup(po);
|
485
|
+
|
486
|
+
if (instance->iotable && instance->iotable->refcount > 1 &&
|
487
|
+
instance->settings && instance->settings->syncdtor) {
|
488
|
+
/* create an async object */
|
489
|
+
SYNCDTOR sd;
|
490
|
+
sd.table = instance->iotable;
|
491
|
+
sd.timer = lcbio_timer_new(instance->iotable, &sd, sync_dtor_cb);
|
492
|
+
sd.stopped = 0;
|
493
|
+
lcbio_async_signal(sd.timer);
|
494
|
+
lcb_log(LOGARGS(instance, WARN), "Running event loop to drain any pending I/O events");
|
495
|
+
do {
|
496
|
+
IOT_START(instance->iotable);
|
497
|
+
} while (!sd.stopped);
|
498
|
+
}
|
499
|
+
|
500
|
+
DESTROY(lcbio_table_unref, iotable);
|
501
|
+
DESTROY(lcb_settings_unref, settings);
|
502
|
+
DESTROY(lcb_histogram_destroy, kv_timings);
|
503
|
+
if (instance->scratch) {
|
504
|
+
delete instance->scratch;
|
505
|
+
instance->scratch = NULL;
|
506
|
+
}
|
507
|
+
|
508
|
+
free(instance->dcpinfo);
|
509
|
+
memset(instance, 0xff, sizeof(*instance));
|
510
|
+
free(instance);
|
511
|
+
#undef DESTROY
|
512
|
+
}
|
513
|
+
|
514
|
+
static void
|
515
|
+
destroy_cb(void *arg)
|
516
|
+
{
|
517
|
+
lcb_t instance = (lcb_t)arg;
|
518
|
+
lcbio_timer_destroy(instance->dtor_timer);
|
519
|
+
lcb_destroy(instance);
|
520
|
+
}
|
521
|
+
|
522
|
+
LIBCOUCHBASE_API
|
523
|
+
void
|
524
|
+
lcb_destroy_async(lcb_t instance, const void *arg)
|
525
|
+
{
|
526
|
+
instance->dtor_timer = lcbio_timer_new(instance->iotable, instance, destroy_cb);
|
527
|
+
instance->settings->dtorarg = (void *)arg;
|
528
|
+
lcbio_async_signal(instance->dtor_timer);
|
529
|
+
}
|
530
|
+
|
531
|
+
LIBCOUCHBASE_API
|
532
|
+
lcb_error_t lcb_connect(lcb_t instance)
|
533
|
+
{
|
534
|
+
lcb_error_t err = lcb_bootstrap_common(instance, LCB_BS_REFRESH_INITIAL);
|
535
|
+
if (err == LCB_SUCCESS) {
|
536
|
+
SYNCMODE_INTERCEPT(instance);
|
537
|
+
} else {
|
538
|
+
return err;
|
539
|
+
}
|
540
|
+
}
|
541
|
+
|
542
|
+
LIBCOUCHBASE_API
|
543
|
+
void *lcb_mem_alloc(lcb_size_t size)
|
544
|
+
{
|
545
|
+
return malloc(size);
|
546
|
+
}
|
547
|
+
|
548
|
+
LIBCOUCHBASE_API
|
549
|
+
void lcb_mem_free(void *ptr)
|
550
|
+
{
|
551
|
+
free(ptr);
|
552
|
+
}
|
553
|
+
|
554
|
+
LCB_INTERNAL_API
|
555
|
+
void lcb_run_loop(lcb_t instance)
|
556
|
+
{
|
557
|
+
IOT_START(instance->iotable);
|
558
|
+
}
|
559
|
+
|
560
|
+
LCB_INTERNAL_API
|
561
|
+
void lcb_stop_loop(lcb_t instance)
|
562
|
+
{
|
563
|
+
IOT_STOP(instance->iotable);
|
564
|
+
}
|
565
|
+
|
566
|
+
void
|
567
|
+
lcb_aspend_init(lcb_ASPEND *ops)
|
568
|
+
{
|
569
|
+
unsigned ii;
|
570
|
+
for (ii = 0; ii < LCB_PENDTYPE_MAX; ++ii) {
|
571
|
+
ops->items[ii] = hashset_create();
|
572
|
+
}
|
573
|
+
ops->count = 0;
|
574
|
+
}
|
575
|
+
|
576
|
+
void
|
577
|
+
lcb_aspend_add(lcb_ASPEND *ops, lcb_ASPENDTYPE type, const void *item)
|
578
|
+
{
|
579
|
+
ops->count++;
|
580
|
+
if (type == LCB_PENDTYPE_COUNTER) {
|
581
|
+
return;
|
582
|
+
}
|
583
|
+
hashset_add(ops->items[type], (void *)item);
|
584
|
+
}
|
585
|
+
|
586
|
+
void
|
587
|
+
lcb_aspend_del(lcb_ASPEND *ops, lcb_ASPENDTYPE type, const void *item)
|
588
|
+
{
|
589
|
+
if (type == LCB_PENDTYPE_COUNTER) {
|
590
|
+
ops->count--;
|
591
|
+
return;
|
592
|
+
}
|
593
|
+
if (hashset_remove(ops->items[type], (void *)item)) {
|
594
|
+
ops->count--;
|
595
|
+
}
|
596
|
+
}
|
597
|
+
|
598
|
+
void
|
599
|
+
lcb_aspend_cleanup(lcb_ASPEND *ops)
|
600
|
+
{
|
601
|
+
unsigned ii;
|
602
|
+
for (ii = 0; ii < LCB_PENDTYPE_MAX; ii++) {
|
603
|
+
hashset_destroy(ops->items[ii]);
|
604
|
+
}
|
605
|
+
}
|
606
|
+
|
607
|
+
LIBCOUCHBASE_API
|
608
|
+
void
|
609
|
+
lcb_sched_enter(lcb_t instance)
|
610
|
+
{
|
611
|
+
mcreq_sched_enter(&instance->cmdq);
|
612
|
+
}
|
613
|
+
LIBCOUCHBASE_API
|
614
|
+
void
|
615
|
+
lcb_sched_leave(lcb_t instance)
|
616
|
+
{
|
617
|
+
mcreq_sched_leave(&instance->cmdq, LCBT_SETTING(instance, sched_implicit_flush));
|
618
|
+
}
|
619
|
+
LIBCOUCHBASE_API
|
620
|
+
void
|
621
|
+
lcb_sched_fail(lcb_t instance)
|
622
|
+
{
|
623
|
+
mcreq_sched_fail(&instance->cmdq);
|
624
|
+
}
|
625
|
+
|
626
|
+
LIBCOUCHBASE_API
|
627
|
+
int
|
628
|
+
lcb_supports_feature(int n)
|
629
|
+
{
|
630
|
+
if (n == LCB_SUPPORTS_SNAPPY) {
|
631
|
+
#ifdef LCB_NO_SNAPPY
|
632
|
+
return 0;
|
633
|
+
#else
|
634
|
+
return 1;
|
635
|
+
#endif
|
636
|
+
}
|
637
|
+
if (n == LCB_SUPPORTS_SSL) {
|
638
|
+
return lcbio_ssl_supported();
|
639
|
+
} else {
|
640
|
+
return 0;
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
|
645
|
+
LCB_INTERNAL_API void lcb_loop_ref(lcb_t instance) {
|
646
|
+
lcb_aspend_add(&instance->pendops, LCB_PENDTYPE_COUNTER, NULL);
|
647
|
+
}
|
648
|
+
LCB_INTERNAL_API void lcb_loop_unref(lcb_t instance) {
|
649
|
+
lcb_aspend_del(&instance->pendops, LCB_PENDTYPE_COUNTER, NULL);
|
650
|
+
lcb_maybe_breakout(instance);
|
651
|
+
}
|
652
|
+
|
653
|
+
LIBCOUCHBASE_API
|
654
|
+
lcb_error_t lcb_enable_timings(lcb_t instance)
|
655
|
+
{
|
656
|
+
if (instance->kv_timings != NULL) {
|
657
|
+
return LCB_KEY_EEXISTS;
|
658
|
+
}
|
659
|
+
instance->kv_timings = lcb_histogram_create();
|
660
|
+
return instance->kv_timings == NULL ? LCB_CLIENT_ENOMEM : LCB_SUCCESS;
|
661
|
+
}
|
662
|
+
|
663
|
+
LIBCOUCHBASE_API
|
664
|
+
lcb_error_t lcb_disable_timings(lcb_t instance)
|
665
|
+
{
|
666
|
+
if (instance->kv_timings == NULL) {
|
667
|
+
return LCB_KEY_ENOENT;
|
668
|
+
}
|
669
|
+
lcb_histogram_destroy(instance->kv_timings);
|
670
|
+
instance->kv_timings = NULL;
|
671
|
+
return LCB_SUCCESS;
|
672
|
+
}
|
673
|
+
|
674
|
+
typedef struct {
|
675
|
+
lcb_t instance;
|
676
|
+
const void *real_cookie;
|
677
|
+
lcb_timings_callback real_cb;
|
678
|
+
} timings_wrapper;
|
679
|
+
|
680
|
+
static void
|
681
|
+
timings_wrapper_callback(const void *cookie, lcb_timeunit_t unit, lcb_U32 start,
|
682
|
+
lcb_U32 end, lcb_U32 val, lcb_U32 max)
|
683
|
+
{
|
684
|
+
const timings_wrapper *wrap = (const timings_wrapper*)cookie;
|
685
|
+
wrap->real_cb(wrap->instance, wrap->real_cookie, unit, start, end, val, max);
|
686
|
+
}
|
687
|
+
|
688
|
+
LIBCOUCHBASE_API
|
689
|
+
lcb_error_t
|
690
|
+
lcb_get_timings(lcb_t instance, const void *cookie, lcb_timings_callback cb)
|
691
|
+
{
|
692
|
+
timings_wrapper wrap;
|
693
|
+
wrap.instance = instance;
|
694
|
+
wrap.real_cookie = cookie;
|
695
|
+
wrap.real_cb = cb;
|
696
|
+
|
697
|
+
if (!instance->kv_timings) {
|
698
|
+
return LCB_KEY_ENOENT;
|
699
|
+
}
|
700
|
+
lcb_histogram_read(instance->kv_timings, &wrap, timings_wrapper_callback);
|
701
|
+
return LCB_SUCCESS;
|
702
|
+
}
|
703
|
+
|
704
|
+
LIBCOUCHBASE_API
|
705
|
+
const char *lcb_strerror(lcb_t instance, lcb_error_t error)
|
706
|
+
{
|
707
|
+
#define X(c, v, t, s) if (error == c) { return s; }
|
708
|
+
LCB_XERR(X)
|
709
|
+
#undef X
|
710
|
+
|
711
|
+
(void)instance;
|
712
|
+
return "Unknown error";
|
713
|
+
}
|
714
|
+
|
715
|
+
LIBCOUCHBASE_API
|
716
|
+
int lcb_get_errtype(lcb_error_t err)
|
717
|
+
{
|
718
|
+
#define X(c, v, t, s) if (err == c) { return t; }
|
719
|
+
LCB_XERR(X)
|
720
|
+
#undef X
|
721
|
+
return -1;
|
722
|
+
}
|