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,954 @@
|
|
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 "mcreq.h"
|
19
|
+
#include "compress.h"
|
20
|
+
#include "sllist-inl.h"
|
21
|
+
#include "internal.h"
|
22
|
+
|
23
|
+
#define PKT_HDRSIZE(pkt) (MCREQ_PKT_BASESIZE + (pkt)->extlen)
|
24
|
+
|
25
|
+
lcb_error_t
|
26
|
+
mcreq_reserve_header(
|
27
|
+
mc_PIPELINE *pipeline, mc_PACKET *packet, uint8_t hdrsize)
|
28
|
+
{
|
29
|
+
int rv;
|
30
|
+
packet->extlen = hdrsize - MCREQ_PKT_BASESIZE;
|
31
|
+
packet->kh_span.size = hdrsize;
|
32
|
+
rv = netbuf_mblock_reserve(&pipeline->nbmgr, &packet->kh_span);
|
33
|
+
if (rv != 0) {
|
34
|
+
return LCB_CLIENT_ENOMEM;
|
35
|
+
}
|
36
|
+
return LCB_SUCCESS;
|
37
|
+
}
|
38
|
+
|
39
|
+
lcb_error_t
|
40
|
+
mcreq_reserve_key(
|
41
|
+
mc_PIPELINE *pipeline, mc_PACKET *packet, uint8_t hdrsize,
|
42
|
+
const lcb_KEYBUF *kreq)
|
43
|
+
{
|
44
|
+
const struct lcb_CONTIGBUF *contig = &kreq->contig;
|
45
|
+
int rv;
|
46
|
+
|
47
|
+
/** Set the key offset which is the start of the key from the buffer */
|
48
|
+
packet->extlen = hdrsize - MCREQ_PKT_BASESIZE;
|
49
|
+
packet->kh_span.size = kreq->contig.nbytes;
|
50
|
+
|
51
|
+
if (kreq->type == LCB_KV_COPY) {
|
52
|
+
/**
|
53
|
+
* If the key is to be copied then just allocate the span size
|
54
|
+
* for the key+24+extras
|
55
|
+
*/
|
56
|
+
packet->kh_span.size += hdrsize;
|
57
|
+
rv = netbuf_mblock_reserve(&pipeline->nbmgr, &packet->kh_span);
|
58
|
+
if (rv != 0) {
|
59
|
+
return LCB_CLIENT_ENOMEM;
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Copy the key into the packet starting at the extras end
|
64
|
+
*/
|
65
|
+
memcpy(SPAN_BUFFER(&packet->kh_span) + hdrsize,
|
66
|
+
contig->bytes,
|
67
|
+
contig->nbytes);
|
68
|
+
|
69
|
+
} else if (kreq->type == LCB_KV_CONTIG) {
|
70
|
+
/**
|
71
|
+
* Don't do any copying.
|
72
|
+
* Assume the key buffer has enough space for the packet as well.
|
73
|
+
*/
|
74
|
+
CREATE_STANDALONE_SPAN(&packet->kh_span, contig->bytes, contig->nbytes);
|
75
|
+
packet->flags |= MCREQ_F_KEY_NOCOPY;
|
76
|
+
|
77
|
+
} else {
|
78
|
+
/** IOVs not supported for keys */
|
79
|
+
return LCB_EINVAL;
|
80
|
+
}
|
81
|
+
|
82
|
+
return LCB_SUCCESS;
|
83
|
+
}
|
84
|
+
|
85
|
+
lcb_error_t
|
86
|
+
mcreq_reserve_value2(mc_PIPELINE *pl, mc_PACKET *pkt, lcb_size_t n)
|
87
|
+
{
|
88
|
+
int rv;
|
89
|
+
pkt->u_value.single.size = n;
|
90
|
+
if (!n) {
|
91
|
+
return LCB_SUCCESS;
|
92
|
+
}
|
93
|
+
|
94
|
+
pkt->flags |= MCREQ_F_HASVALUE;
|
95
|
+
rv = netbuf_mblock_reserve(&pl->nbmgr, &pkt->u_value.single);
|
96
|
+
if (rv) {
|
97
|
+
return LCB_CLIENT_ENOMEM;
|
98
|
+
}
|
99
|
+
return LCB_SUCCESS;
|
100
|
+
}
|
101
|
+
|
102
|
+
lcb_error_t
|
103
|
+
mcreq_reserve_value(
|
104
|
+
mc_PIPELINE *pipeline, mc_PACKET *packet, const lcb_VALBUF *vreq)
|
105
|
+
{
|
106
|
+
const lcb_CONTIGBUF *contig = &vreq->u_buf.contig;
|
107
|
+
nb_SPAN *vspan = &packet->u_value.single;
|
108
|
+
int rv;
|
109
|
+
|
110
|
+
if (vreq->vtype == LCB_KV_COPY) {
|
111
|
+
/** Copy the value into a single SPAN */
|
112
|
+
if (! (vspan->size = vreq->u_buf.contig.nbytes)) {
|
113
|
+
return LCB_SUCCESS;
|
114
|
+
}
|
115
|
+
rv = netbuf_mblock_reserve(&pipeline->nbmgr, vspan);
|
116
|
+
|
117
|
+
if (rv != 0) {
|
118
|
+
return LCB_CLIENT_ENOMEM;
|
119
|
+
}
|
120
|
+
|
121
|
+
memcpy(SPAN_BUFFER(vspan), contig->bytes, contig->nbytes);
|
122
|
+
|
123
|
+
} else if (vreq->vtype == LCB_KV_CONTIG) {
|
124
|
+
/** It's still contiguous so make it a 'standalone' span */
|
125
|
+
CREATE_STANDALONE_SPAN(vspan, contig->bytes, contig->nbytes);
|
126
|
+
packet->flags |= MCREQ_F_VALUE_NOCOPY;
|
127
|
+
|
128
|
+
} else if (vreq->vtype == LCB_KV_IOV) {
|
129
|
+
/** Multiple spans, no copy */
|
130
|
+
unsigned int ii;
|
131
|
+
const lcb_FRAGBUF *msrc = &vreq->u_buf.multi;
|
132
|
+
lcb_FRAGBUF *mdst = &packet->u_value.multi;
|
133
|
+
|
134
|
+
packet->flags |= MCREQ_F_VALUE_IOV | MCREQ_F_VALUE_NOCOPY;
|
135
|
+
mdst->niov = msrc->niov;
|
136
|
+
mdst->iov = malloc(mdst->niov * sizeof(*mdst->iov));
|
137
|
+
mdst->total_length = 0;
|
138
|
+
|
139
|
+
for (ii = 0; ii < mdst->niov; ii++) {
|
140
|
+
mdst->iov[ii] = msrc->iov[ii];
|
141
|
+
mdst->total_length += mdst->iov[ii].iov_len;
|
142
|
+
}
|
143
|
+
} else if (vreq->vtype == LCB_KV_IOVCOPY) {
|
144
|
+
/** Multiple input buffers, normal copying output buffer */
|
145
|
+
unsigned int ii, cur_offset;
|
146
|
+
const lcb_FRAGBUF *msrc = &vreq->u_buf.multi;
|
147
|
+
|
148
|
+
if (msrc->total_length) {
|
149
|
+
vspan->size = msrc->total_length;
|
150
|
+
} else {
|
151
|
+
vspan->size = 0;
|
152
|
+
for (ii = 0; ii < msrc->niov; ii++) {
|
153
|
+
vspan->size += msrc->iov[ii].iov_len;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
rv = netbuf_mblock_reserve(&pipeline->nbmgr, vspan);
|
158
|
+
if (rv != 0) {
|
159
|
+
return LCB_CLIENT_ENOMEM;
|
160
|
+
}
|
161
|
+
|
162
|
+
for (ii = 0, cur_offset = 0; ii < msrc->niov; ii++) {
|
163
|
+
char *buf = SPAN_BUFFER(vspan) + cur_offset;
|
164
|
+
memcpy(buf, msrc->iov[ii].iov_base, msrc->iov[ii].iov_len);
|
165
|
+
cur_offset += msrc->iov[ii].iov_len;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
packet->flags |= MCREQ_F_HASVALUE;
|
170
|
+
return LCB_SUCCESS;
|
171
|
+
}
|
172
|
+
|
173
|
+
static int
|
174
|
+
pkt_tmo_compar(sllist_node *a, sllist_node *b)
|
175
|
+
{
|
176
|
+
mc_PACKET *pa, *pb;
|
177
|
+
hrtime_t tmo_a, tmo_b;
|
178
|
+
|
179
|
+
pa = SLLIST_ITEM(a, mc_PACKET, slnode);
|
180
|
+
pb = SLLIST_ITEM(b, mc_PACKET, slnode);
|
181
|
+
|
182
|
+
tmo_a = MCREQ_PKT_RDATA(pa)->start;
|
183
|
+
tmo_b = MCREQ_PKT_RDATA(pb)->start;
|
184
|
+
|
185
|
+
if (tmo_a == tmo_b) {
|
186
|
+
return 0;
|
187
|
+
} else if (tmo_a < tmo_b) {
|
188
|
+
return -1;
|
189
|
+
} else {
|
190
|
+
return 1;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
void
|
195
|
+
mcreq_reenqueue_packet(mc_PIPELINE *pipeline, mc_PACKET *packet)
|
196
|
+
{
|
197
|
+
sllist_root *reqs = &pipeline->requests;
|
198
|
+
mcreq_enqueue_packet(pipeline, packet);
|
199
|
+
sllist_remove(reqs, &packet->slnode);
|
200
|
+
sllist_insert_sorted(reqs, &packet->slnode, pkt_tmo_compar);
|
201
|
+
}
|
202
|
+
|
203
|
+
void
|
204
|
+
mcreq_enqueue_packet(mc_PIPELINE *pipeline, mc_PACKET *packet)
|
205
|
+
{
|
206
|
+
nb_SPAN *vspan = &packet->u_value.single;
|
207
|
+
sllist_append(&pipeline->requests, &packet->slnode);
|
208
|
+
netbuf_enqueue_span(&pipeline->nbmgr, &packet->kh_span);
|
209
|
+
|
210
|
+
if (!(packet->flags & MCREQ_F_HASVALUE)) {
|
211
|
+
goto GT_ENQUEUE_PDU;
|
212
|
+
}
|
213
|
+
|
214
|
+
if (packet->flags & MCREQ_F_VALUE_IOV) {
|
215
|
+
unsigned int ii;
|
216
|
+
lcb_FRAGBUF *multi = &packet->u_value.multi;
|
217
|
+
for (ii = 0; ii < multi->niov; ii++) {
|
218
|
+
netbuf_enqueue(&pipeline->nbmgr, (nb_IOV *)multi->iov + ii);
|
219
|
+
}
|
220
|
+
|
221
|
+
} else if (vspan->size) {
|
222
|
+
netbuf_enqueue_span(&pipeline->nbmgr, vspan);
|
223
|
+
}
|
224
|
+
|
225
|
+
GT_ENQUEUE_PDU:
|
226
|
+
netbuf_pdu_enqueue(&pipeline->nbmgr, packet, offsetof(mc_PACKET, sl_flushq));
|
227
|
+
}
|
228
|
+
|
229
|
+
void
|
230
|
+
mcreq_wipe_packet(mc_PIPELINE *pipeline, mc_PACKET *packet)
|
231
|
+
{
|
232
|
+
if (! (packet->flags & MCREQ_F_KEY_NOCOPY)) {
|
233
|
+
if (packet->flags & MCREQ_F_DETACHED) {
|
234
|
+
free(SPAN_BUFFER(&packet->kh_span));
|
235
|
+
} else {
|
236
|
+
netbuf_mblock_release(&pipeline->nbmgr, &packet->kh_span);
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
if (! (packet->flags & MCREQ_F_HASVALUE)) {
|
241
|
+
return;
|
242
|
+
}
|
243
|
+
|
244
|
+
if (packet->flags & MCREQ_F_VALUE_NOCOPY) {
|
245
|
+
if (packet->flags & MCREQ_F_VALUE_IOV) {
|
246
|
+
free(packet->u_value.multi.iov);
|
247
|
+
}
|
248
|
+
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
|
252
|
+
if (packet->flags & MCREQ_F_DETACHED) {
|
253
|
+
free(SPAN_BUFFER(&packet->u_value.single));
|
254
|
+
} else {
|
255
|
+
netbuf_mblock_release(&pipeline->nbmgr, &packet->u_value.single);
|
256
|
+
}
|
257
|
+
|
258
|
+
}
|
259
|
+
|
260
|
+
mc_PACKET *
|
261
|
+
mcreq_allocate_packet(mc_PIPELINE *pipeline)
|
262
|
+
{
|
263
|
+
nb_SPAN span;
|
264
|
+
int rv;
|
265
|
+
mc_PACKET *ret;
|
266
|
+
span.size = sizeof(*ret);
|
267
|
+
|
268
|
+
rv = netbuf_mblock_reserve(&pipeline->reqpool, &span);
|
269
|
+
if (rv != 0) {
|
270
|
+
return NULL;
|
271
|
+
}
|
272
|
+
|
273
|
+
ret = (void *) SPAN_MBUFFER_NC(&span);
|
274
|
+
ret->alloc_parent = span.parent;
|
275
|
+
ret->flags = 0;
|
276
|
+
ret->retries = 0;
|
277
|
+
ret->opaque = pipeline->parent->seq++;
|
278
|
+
return ret;
|
279
|
+
}
|
280
|
+
|
281
|
+
void
|
282
|
+
mcreq_release_packet(mc_PIPELINE *pipeline, mc_PACKET *packet)
|
283
|
+
{
|
284
|
+
nb_SPAN span;
|
285
|
+
if (packet->flags & MCREQ_F_DETACHED) {
|
286
|
+
sllist_iterator iter;
|
287
|
+
mc_EXPACKET *epkt = (mc_EXPACKET *)packet;
|
288
|
+
|
289
|
+
SLLIST_ITERFOR(&epkt->data, &iter) {
|
290
|
+
mc_EPKTDATUM *d = SLLIST_ITEM(iter.cur, mc_EPKTDATUM, slnode);
|
291
|
+
sllist_iter_remove(&epkt->data, &iter);
|
292
|
+
d->dtorfn(d);
|
293
|
+
}
|
294
|
+
free(epkt);
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
|
298
|
+
span.size = sizeof(*packet);
|
299
|
+
span.parent = packet->alloc_parent;
|
300
|
+
span.offset = (char *)packet - packet->alloc_parent->root;
|
301
|
+
|
302
|
+
netbuf_mblock_release(&pipeline->reqpool, &span);
|
303
|
+
}
|
304
|
+
|
305
|
+
#define MCREQ_DETACH_WIPESRC 1
|
306
|
+
|
307
|
+
mc_PACKET *
|
308
|
+
mcreq_renew_packet(const mc_PACKET *src)
|
309
|
+
{
|
310
|
+
char *kdata, *vdata;
|
311
|
+
unsigned nvdata;
|
312
|
+
mc_PACKET *dst;
|
313
|
+
mc_EXPACKET *edst = calloc(1, sizeof(*edst));
|
314
|
+
|
315
|
+
dst = &edst->base;
|
316
|
+
*dst = *src;
|
317
|
+
|
318
|
+
kdata = malloc(src->kh_span.size);
|
319
|
+
memcpy(kdata, SPAN_BUFFER(&src->kh_span), src->kh_span.size);
|
320
|
+
CREATE_STANDALONE_SPAN(&dst->kh_span, kdata, src->kh_span.size);
|
321
|
+
|
322
|
+
dst->flags &= ~(MCREQ_F_KEY_NOCOPY|MCREQ_F_VALUE_NOCOPY|MCREQ_F_VALUE_IOV);
|
323
|
+
dst->flags |= MCREQ_F_DETACHED;
|
324
|
+
dst->alloc_parent = NULL;
|
325
|
+
dst->sl_flushq.next = NULL;
|
326
|
+
dst->slnode.next = NULL;
|
327
|
+
dst->retries = src->retries;
|
328
|
+
|
329
|
+
if (src->flags & MCREQ_F_HASVALUE) {
|
330
|
+
/** Get the length */
|
331
|
+
if (src->flags & MCREQ_F_VALUE_IOV) {
|
332
|
+
unsigned ii;
|
333
|
+
unsigned offset = 0;
|
334
|
+
|
335
|
+
nvdata = src->u_value.multi.total_length;
|
336
|
+
vdata = malloc(nvdata);
|
337
|
+
for (ii = 0; ii < src->u_value.multi.niov; ii++) {
|
338
|
+
const lcb_IOV *iov = src->u_value.multi.iov + ii;
|
339
|
+
|
340
|
+
memcpy(vdata + offset, iov->iov_base, iov->iov_len);
|
341
|
+
offset += iov->iov_len;
|
342
|
+
}
|
343
|
+
} else {
|
344
|
+
protocol_binary_request_header hdr;
|
345
|
+
const nb_SPAN *origspan = &src->u_value.single;
|
346
|
+
mcreq_read_hdr(dst, &hdr);
|
347
|
+
|
348
|
+
if (hdr.request.datatype & PROTOCOL_BINARY_DATATYPE_COMPRESSED) {
|
349
|
+
/* For compressed payloads we need to uncompress it first
|
350
|
+
* because it may be forwarded to a server without compression.
|
351
|
+
* TODO: might be more clever to check a setting flag somewhere
|
352
|
+
* and see if we should do this. */
|
353
|
+
|
354
|
+
lcb_SIZE n_inflated;
|
355
|
+
const void *inflated;
|
356
|
+
int rv;
|
357
|
+
|
358
|
+
vdata = NULL;
|
359
|
+
rv = mcreq_inflate_value(SPAN_BUFFER(origspan), origspan->size,
|
360
|
+
&inflated, &n_inflated, (void**)&vdata);
|
361
|
+
|
362
|
+
assert(vdata == inflated);
|
363
|
+
|
364
|
+
if (rv != 0) {
|
365
|
+
return NULL;
|
366
|
+
}
|
367
|
+
nvdata = n_inflated;
|
368
|
+
hdr.request.datatype &= ~PROTOCOL_BINARY_DATATYPE_COMPRESSED;
|
369
|
+
hdr.request.bodylen = htonl(
|
370
|
+
ntohs(hdr.request.keylen) +
|
371
|
+
hdr.request.extlen +
|
372
|
+
n_inflated);
|
373
|
+
mcreq_write_hdr(dst, &hdr);
|
374
|
+
|
375
|
+
} else {
|
376
|
+
nvdata = origspan->size;
|
377
|
+
vdata = malloc(nvdata);
|
378
|
+
memcpy(vdata, SPAN_BUFFER(origspan), nvdata);
|
379
|
+
}
|
380
|
+
}
|
381
|
+
|
382
|
+
/* Declare the value as a standalone malloc'd span */
|
383
|
+
CREATE_STANDALONE_SPAN(&dst->u_value.single, vdata, nvdata);
|
384
|
+
}
|
385
|
+
|
386
|
+
if (src->flags & MCREQ_F_DETACHED) {
|
387
|
+
mc_EXPACKET *esrc = (mc_EXPACKET *)src;
|
388
|
+
sllist_iterator iter;
|
389
|
+
SLLIST_ITERFOR(&esrc->data, &iter) {
|
390
|
+
sllist_node *cur = iter.cur;
|
391
|
+
sllist_iter_remove(&esrc->data, &iter);
|
392
|
+
sllist_append(&edst->data, cur);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
return dst;
|
396
|
+
}
|
397
|
+
|
398
|
+
int
|
399
|
+
mcreq_epkt_insert(mc_EXPACKET *ep, mc_EPKTDATUM *datum)
|
400
|
+
{
|
401
|
+
if (!(ep->base.flags & MCREQ_F_DETACHED)) {
|
402
|
+
return -1;
|
403
|
+
}
|
404
|
+
assert(!sllist_contains(&ep->data, &datum->slnode));
|
405
|
+
sllist_append(&ep->data, &datum->slnode);
|
406
|
+
return 0;
|
407
|
+
}
|
408
|
+
|
409
|
+
mc_EPKTDATUM *
|
410
|
+
mcreq_epkt_find(mc_EXPACKET *ep, const char *key)
|
411
|
+
{
|
412
|
+
sllist_iterator iter;
|
413
|
+
SLLIST_ITERFOR(&ep->data, &iter) {
|
414
|
+
mc_EPKTDATUM *d = SLLIST_ITEM(iter.cur, mc_EPKTDATUM, slnode);
|
415
|
+
if (!strcmp(key, d->key)) {
|
416
|
+
return d;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
return NULL;
|
420
|
+
}
|
421
|
+
|
422
|
+
void
|
423
|
+
mcreq_map_key(mc_CMDQUEUE *queue,
|
424
|
+
const lcb_KEYBUF *key, const lcb_KEYBUF *hashkey,
|
425
|
+
unsigned nhdr, int *vbid, int *srvix)
|
426
|
+
{
|
427
|
+
const void *hk;
|
428
|
+
size_t nhk = 0;
|
429
|
+
if (hashkey) {
|
430
|
+
if (hashkey->type == LCB_KV_COPY && hashkey->contig.bytes != NULL) {
|
431
|
+
hk = hashkey->contig.bytes;
|
432
|
+
nhk = hashkey->contig.nbytes;
|
433
|
+
} else if (hashkey->type == LCB_KV_VBID) {
|
434
|
+
*vbid = hashkey->contig.nbytes;
|
435
|
+
*srvix = lcbvb_vbmaster(queue->config, *vbid);
|
436
|
+
return;
|
437
|
+
}
|
438
|
+
}
|
439
|
+
if (!nhk) {
|
440
|
+
if (key->type == LCB_KV_COPY) {
|
441
|
+
hk = key->contig.bytes;
|
442
|
+
nhk = key->contig.nbytes;
|
443
|
+
} else {
|
444
|
+
const char *buf = key->contig.bytes;
|
445
|
+
buf += nhdr;
|
446
|
+
hk = buf;
|
447
|
+
nhk = key->contig.nbytes - nhdr;
|
448
|
+
}
|
449
|
+
}
|
450
|
+
lcbvb_map_key(queue->config, hk, nhk, vbid, srvix);
|
451
|
+
}
|
452
|
+
|
453
|
+
lcb_error_t
|
454
|
+
mcreq_basic_packet(
|
455
|
+
mc_CMDQUEUE *queue, const lcb_CMDBASE *cmd,
|
456
|
+
protocol_binary_request_header *req, lcb_uint8_t extlen,
|
457
|
+
mc_PACKET **packet, mc_PIPELINE **pipeline, int options)
|
458
|
+
{
|
459
|
+
int vb, srvix;
|
460
|
+
|
461
|
+
if (!queue->config) {
|
462
|
+
return LCB_CLIENT_ETMPFAIL;
|
463
|
+
}
|
464
|
+
|
465
|
+
mcreq_map_key(queue, &cmd->key, &cmd->_hashkey,
|
466
|
+
sizeof(*req) + extlen, &vb, &srvix);
|
467
|
+
if (srvix > -1 && srvix < (int)queue->npipelines) {
|
468
|
+
*pipeline = queue->pipelines[srvix];
|
469
|
+
|
470
|
+
} else {
|
471
|
+
if ((options & MCREQ_BASICPACKET_F_FALLBACKOK) && queue->fallback) {
|
472
|
+
*pipeline = queue->fallback;
|
473
|
+
} else {
|
474
|
+
return LCB_NO_MATCHING_SERVER;
|
475
|
+
}
|
476
|
+
}
|
477
|
+
|
478
|
+
*packet = mcreq_allocate_packet(*pipeline);
|
479
|
+
|
480
|
+
mcreq_reserve_key(*pipeline, *packet, sizeof(*req) + extlen, &cmd->key);
|
481
|
+
|
482
|
+
req->request.keylen = htons((*packet)->kh_span.size - PKT_HDRSIZE(*packet));
|
483
|
+
req->request.vbucket = htons(vb);
|
484
|
+
req->request.extlen = extlen;
|
485
|
+
return LCB_SUCCESS;
|
486
|
+
}
|
487
|
+
|
488
|
+
void
|
489
|
+
mcreq_get_key(const mc_PACKET *packet, const void **key, lcb_size_t *nkey)
|
490
|
+
{
|
491
|
+
*key = SPAN_BUFFER(&packet->kh_span) + PKT_HDRSIZE(packet);
|
492
|
+
*nkey = packet->kh_span.size - PKT_HDRSIZE(packet);
|
493
|
+
}
|
494
|
+
|
495
|
+
lcb_uint32_t
|
496
|
+
mcreq_get_bodysize(const mc_PACKET *packet)
|
497
|
+
{
|
498
|
+
lcb_uint32_t ret;
|
499
|
+
char *retptr = SPAN_BUFFER(&packet->kh_span) + 8;
|
500
|
+
if ((uintptr_t)retptr % sizeof(ret) == 0) {
|
501
|
+
return ntohl(*(lcb_uint32_t*) (void *)retptr);
|
502
|
+
} else {
|
503
|
+
memcpy(&ret, retptr, sizeof(ret));
|
504
|
+
return ntohl(ret);
|
505
|
+
}
|
506
|
+
}
|
507
|
+
|
508
|
+
uint16_t
|
509
|
+
mcreq_get_vbucket(const mc_PACKET *packet)
|
510
|
+
{
|
511
|
+
uint16_t ret;
|
512
|
+
char *retptr = SPAN_BUFFER(&packet->kh_span) + 6;
|
513
|
+
if ((uintptr_t)retptr % sizeof(ret) == 0) {
|
514
|
+
return ntohs(*(uint16_t*)(void*)retptr);
|
515
|
+
} else {
|
516
|
+
memcpy(&ret, retptr, sizeof ret);
|
517
|
+
return ntohs(ret);
|
518
|
+
}
|
519
|
+
}
|
520
|
+
|
521
|
+
uint32_t
|
522
|
+
mcreq_get_size(const mc_PACKET *packet)
|
523
|
+
{
|
524
|
+
uint32_t sz = packet->kh_span.size;
|
525
|
+
if (packet->flags & MCREQ_F_HASVALUE) {
|
526
|
+
if (packet->flags & MCREQ_F_VALUE_IOV) {
|
527
|
+
sz += packet->u_value.multi.total_length;
|
528
|
+
} else {
|
529
|
+
sz += packet->u_value.single.size;
|
530
|
+
}
|
531
|
+
}
|
532
|
+
return sz;
|
533
|
+
}
|
534
|
+
|
535
|
+
void
|
536
|
+
mcreq_pipeline_cleanup(mc_PIPELINE *pipeline)
|
537
|
+
{
|
538
|
+
netbuf_cleanup(&pipeline->nbmgr);
|
539
|
+
netbuf_cleanup(&pipeline->reqpool);
|
540
|
+
}
|
541
|
+
|
542
|
+
int
|
543
|
+
mcreq_pipeline_init(mc_PIPELINE *pipeline)
|
544
|
+
{
|
545
|
+
nb_SETTINGS settings;
|
546
|
+
netbuf_default_settings(&settings);
|
547
|
+
|
548
|
+
/** Initialize datapool */
|
549
|
+
netbuf_init(&pipeline->nbmgr, &settings);
|
550
|
+
|
551
|
+
/** Initialize request pool */
|
552
|
+
settings.data_basealloc = sizeof(mc_PACKET) * 32;
|
553
|
+
netbuf_init(&pipeline->reqpool, &settings);
|
554
|
+
return 0;
|
555
|
+
}
|
556
|
+
|
557
|
+
void
|
558
|
+
mcreq_queue_add_pipelines(
|
559
|
+
mc_CMDQUEUE *queue, mc_PIPELINE * const *pipelines, unsigned npipelines,
|
560
|
+
lcbvb_CONFIG* config)
|
561
|
+
{
|
562
|
+
unsigned ii;
|
563
|
+
|
564
|
+
lcb_assert(queue->pipelines == NULL);
|
565
|
+
queue->npipelines = npipelines;
|
566
|
+
queue->_npipelines_ex = queue->npipelines;
|
567
|
+
queue->pipelines = malloc(sizeof(*pipelines) * (npipelines + 1));
|
568
|
+
queue->config = config;
|
569
|
+
|
570
|
+
memcpy(queue->pipelines, pipelines, sizeof(*pipelines) * npipelines);
|
571
|
+
|
572
|
+
free(queue->scheds);
|
573
|
+
queue->scheds = calloc(npipelines+1, 1);
|
574
|
+
|
575
|
+
for (ii = 0; ii < npipelines; ii++) {
|
576
|
+
pipelines[ii]->parent = queue;
|
577
|
+
pipelines[ii]->index = ii;
|
578
|
+
}
|
579
|
+
|
580
|
+
if (queue->fallback) {
|
581
|
+
queue->fallback->index = npipelines;
|
582
|
+
queue->pipelines[queue->npipelines] = queue->fallback;
|
583
|
+
queue->_npipelines_ex++;
|
584
|
+
}
|
585
|
+
}
|
586
|
+
|
587
|
+
mc_PIPELINE **
|
588
|
+
mcreq_queue_take_pipelines(mc_CMDQUEUE *queue, unsigned *count)
|
589
|
+
{
|
590
|
+
mc_PIPELINE **ret = queue->pipelines;
|
591
|
+
*count = queue->npipelines;
|
592
|
+
queue->pipelines = NULL;
|
593
|
+
queue->npipelines = 0;
|
594
|
+
return ret;
|
595
|
+
}
|
596
|
+
|
597
|
+
int
|
598
|
+
mcreq_queue_init(mc_CMDQUEUE *queue)
|
599
|
+
{
|
600
|
+
queue->seq = 0;
|
601
|
+
queue->pipelines = NULL;
|
602
|
+
queue->scheds = NULL;
|
603
|
+
queue->fallback = NULL;
|
604
|
+
queue->npipelines = 0;
|
605
|
+
return 0;
|
606
|
+
}
|
607
|
+
|
608
|
+
void
|
609
|
+
mcreq_queue_cleanup(mc_CMDQUEUE *queue)
|
610
|
+
{
|
611
|
+
if (queue->fallback) {
|
612
|
+
mcreq_pipeline_cleanup(queue->fallback);
|
613
|
+
free(queue->fallback);
|
614
|
+
queue->fallback = NULL;
|
615
|
+
}
|
616
|
+
free(queue->scheds);
|
617
|
+
free(queue->pipelines);
|
618
|
+
queue->scheds = NULL;
|
619
|
+
}
|
620
|
+
|
621
|
+
void
|
622
|
+
mcreq_sched_enter(mc_CMDQUEUE *queue)
|
623
|
+
{
|
624
|
+
queue->ctxenter = 1;
|
625
|
+
}
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
static void
|
630
|
+
queuectx_leave(mc_CMDQUEUE *queue, int success, int flush)
|
631
|
+
{
|
632
|
+
unsigned ii;
|
633
|
+
|
634
|
+
if (queue->ctxenter) {
|
635
|
+
queue->ctxenter = 0;
|
636
|
+
}
|
637
|
+
|
638
|
+
for (ii = 0; ii < queue->_npipelines_ex; ii++) {
|
639
|
+
mc_PIPELINE *pipeline;
|
640
|
+
sllist_node *ll_next, *ll;
|
641
|
+
|
642
|
+
if (!queue->scheds[ii]) {
|
643
|
+
continue;
|
644
|
+
}
|
645
|
+
|
646
|
+
pipeline = queue->pipelines[ii];
|
647
|
+
ll = SLLIST_FIRST(&pipeline->ctxqueued);
|
648
|
+
|
649
|
+
while (ll) {
|
650
|
+
mc_PACKET *pkt = SLLIST_ITEM(ll, mc_PACKET, slnode);
|
651
|
+
ll_next = ll->next;
|
652
|
+
|
653
|
+
if (success) {
|
654
|
+
mcreq_enqueue_packet(pipeline, pkt);
|
655
|
+
} else {
|
656
|
+
if (pkt->flags & MCREQ_F_REQEXT) {
|
657
|
+
mc_REQDATAEX *rd = pkt->u_rdata.exdata;
|
658
|
+
if (rd->procs->fail_dtor) {
|
659
|
+
rd->procs->fail_dtor(pkt);
|
660
|
+
}
|
661
|
+
}
|
662
|
+
mcreq_wipe_packet(pipeline, pkt);
|
663
|
+
mcreq_release_packet(pipeline, pkt);
|
664
|
+
}
|
665
|
+
|
666
|
+
ll = ll_next;
|
667
|
+
}
|
668
|
+
SLLIST_FIRST(&pipeline->ctxqueued) = pipeline->ctxqueued.last = NULL;
|
669
|
+
if (flush) {
|
670
|
+
pipeline->flush_start(pipeline);
|
671
|
+
}
|
672
|
+
queue->scheds[ii] = 0;
|
673
|
+
}
|
674
|
+
}
|
675
|
+
|
676
|
+
void
|
677
|
+
mcreq_sched_leave(mc_CMDQUEUE *queue, int do_flush)
|
678
|
+
{
|
679
|
+
queuectx_leave(queue, 1, do_flush);
|
680
|
+
}
|
681
|
+
|
682
|
+
void
|
683
|
+
mcreq_sched_fail(mc_CMDQUEUE *queue)
|
684
|
+
{
|
685
|
+
queuectx_leave(queue, 0, 0);
|
686
|
+
}
|
687
|
+
|
688
|
+
void
|
689
|
+
mcreq_sched_add(mc_PIPELINE *pipeline, mc_PACKET *pkt)
|
690
|
+
{
|
691
|
+
mc_CMDQUEUE *cq = pipeline->parent;
|
692
|
+
if (!cq->scheds[pipeline->index]) {
|
693
|
+
cq->scheds[pipeline->index] = 1;
|
694
|
+
}
|
695
|
+
sllist_append(&pipeline->ctxqueued, &pkt->slnode);
|
696
|
+
}
|
697
|
+
|
698
|
+
static mc_PACKET *
|
699
|
+
pipeline_find(mc_PIPELINE *pipeline, lcb_uint32_t opaque, int do_remove)
|
700
|
+
{
|
701
|
+
sllist_iterator iter;
|
702
|
+
SLLIST_ITERFOR(&pipeline->requests, &iter) {
|
703
|
+
mc_PACKET *pkt = SLLIST_ITEM(iter.cur, mc_PACKET, slnode);
|
704
|
+
if (pkt->opaque == opaque) {
|
705
|
+
if (do_remove) {
|
706
|
+
sllist_iter_remove(&pipeline->requests, &iter);
|
707
|
+
}
|
708
|
+
return pkt;
|
709
|
+
}
|
710
|
+
}
|
711
|
+
return NULL;
|
712
|
+
}
|
713
|
+
|
714
|
+
mc_PACKET *
|
715
|
+
mcreq_pipeline_find(mc_PIPELINE *pipeline, lcb_uint32_t opaque)
|
716
|
+
{
|
717
|
+
return pipeline_find(pipeline, opaque, 0);
|
718
|
+
}
|
719
|
+
|
720
|
+
mc_PACKET *
|
721
|
+
mcreq_pipeline_remove(mc_PIPELINE *pipeline, lcb_uint32_t opaque)
|
722
|
+
{
|
723
|
+
return pipeline_find(pipeline, opaque, 1);
|
724
|
+
}
|
725
|
+
|
726
|
+
void
|
727
|
+
mcreq_packet_done(mc_PIPELINE *pipeline, mc_PACKET *pkt)
|
728
|
+
{
|
729
|
+
assert(pkt->flags & MCREQ_F_FLUSHED);
|
730
|
+
assert(pkt->flags & MCREQ_F_INVOKED);
|
731
|
+
if (pkt->flags & MCREQ_UBUF_FLAGS) {
|
732
|
+
void *kbuf, *vbuf;
|
733
|
+
const void *cookie;
|
734
|
+
|
735
|
+
cookie = MCREQ_PKT_COOKIE(pkt);
|
736
|
+
if (pkt->flags & MCREQ_F_KEY_NOCOPY) {
|
737
|
+
kbuf = SPAN_BUFFER(&pkt->kh_span);
|
738
|
+
} else {
|
739
|
+
kbuf = NULL;
|
740
|
+
}
|
741
|
+
if (pkt->flags & MCREQ_F_VALUE_NOCOPY) {
|
742
|
+
if (pkt->flags & MCREQ_F_VALUE_IOV) {
|
743
|
+
vbuf = pkt->u_value.multi.iov->iov_base;
|
744
|
+
} else {
|
745
|
+
vbuf = SPAN_SABUFFER_NC(&pkt->u_value.single);
|
746
|
+
}
|
747
|
+
} else {
|
748
|
+
vbuf = NULL;
|
749
|
+
}
|
750
|
+
|
751
|
+
pipeline->buf_done_callback(pipeline, cookie, kbuf, vbuf);
|
752
|
+
}
|
753
|
+
mcreq_wipe_packet(pipeline, pkt);
|
754
|
+
mcreq_release_packet(pipeline, pkt);
|
755
|
+
}
|
756
|
+
|
757
|
+
void
|
758
|
+
mcreq_reset_timeouts(mc_PIPELINE *pl, lcb_U64 nstime)
|
759
|
+
{
|
760
|
+
sllist_node *nn;
|
761
|
+
SLLIST_ITERBASIC(&pl->requests, nn) {
|
762
|
+
mc_PACKET *pkt = SLLIST_ITEM(nn, mc_PACKET, slnode);
|
763
|
+
MCREQ_PKT_RDATA(pkt)->start = nstime;
|
764
|
+
}
|
765
|
+
}
|
766
|
+
|
767
|
+
unsigned
|
768
|
+
mcreq_pipeline_timeout(
|
769
|
+
mc_PIPELINE *pl, lcb_error_t err, mcreq_pktfail_fn failcb, void *cbarg,
|
770
|
+
hrtime_t oldest_valid, hrtime_t *oldest_start)
|
771
|
+
{
|
772
|
+
sllist_iterator iter;
|
773
|
+
unsigned count = 0;
|
774
|
+
|
775
|
+
SLLIST_ITERFOR(&pl->requests, &iter) {
|
776
|
+
mc_PACKET *pkt = SLLIST_ITEM(iter.cur, mc_PACKET, slnode);
|
777
|
+
mc_REQDATA *rd = MCREQ_PKT_RDATA(pkt);
|
778
|
+
|
779
|
+
/**
|
780
|
+
* oldest_valid contains the LOWEST timestamp we can admit to being
|
781
|
+
* acceptable. If the current command is newer (i.e. has a higher
|
782
|
+
* timestamp) then we break the iteration and return.
|
783
|
+
*/
|
784
|
+
if (oldest_valid && rd->start > oldest_valid) {
|
785
|
+
if (oldest_start) {
|
786
|
+
*oldest_start = rd->start;
|
787
|
+
}
|
788
|
+
return count;
|
789
|
+
}
|
790
|
+
|
791
|
+
sllist_iter_remove(&pl->requests, &iter);
|
792
|
+
failcb(pl, pkt, err, cbarg);
|
793
|
+
mcreq_packet_handled(pl, pkt);
|
794
|
+
count++;
|
795
|
+
}
|
796
|
+
return count;
|
797
|
+
}
|
798
|
+
|
799
|
+
unsigned
|
800
|
+
mcreq_pipeline_fail(
|
801
|
+
mc_PIPELINE *pl, lcb_error_t err, mcreq_pktfail_fn failcb, void *arg)
|
802
|
+
{
|
803
|
+
return mcreq_pipeline_timeout(pl, err, failcb, arg, 0, NULL);
|
804
|
+
}
|
805
|
+
|
806
|
+
void
|
807
|
+
mcreq_iterwipe(mc_CMDQUEUE *queue, mc_PIPELINE *src,
|
808
|
+
mcreq_iterwipe_fn callback, void *arg)
|
809
|
+
{
|
810
|
+
sllist_iterator iter;
|
811
|
+
|
812
|
+
SLLIST_ITERFOR(&src->requests, &iter) {
|
813
|
+
int rv;
|
814
|
+
mc_PACKET *orig = SLLIST_ITEM(iter.cur, mc_PACKET, slnode);
|
815
|
+
rv = callback(queue, src, orig, arg);
|
816
|
+
if (rv == MCREQ_REMOVE_PACKET) {
|
817
|
+
sllist_iter_remove(&src->requests, &iter);
|
818
|
+
}
|
819
|
+
}
|
820
|
+
}
|
821
|
+
|
822
|
+
#include "mcreq-flush-inl.h"
|
823
|
+
typedef struct {
|
824
|
+
mc_PIPELINE base;
|
825
|
+
mcreq_fallback_cb handler;
|
826
|
+
} mc_FALLBACKPL;
|
827
|
+
|
828
|
+
static void
|
829
|
+
do_fallback_flush(mc_PIPELINE *pipeline)
|
830
|
+
{
|
831
|
+
nb_IOV iov;
|
832
|
+
unsigned nb;
|
833
|
+
int nused;
|
834
|
+
sllist_iterator iter;
|
835
|
+
mc_FALLBACKPL *fpl = (mc_FALLBACKPL*)pipeline;
|
836
|
+
|
837
|
+
while ((nb = mcreq_flush_iov_fill(pipeline, &iov, 1, &nused))) {
|
838
|
+
mcreq_flush_done(pipeline, nb, nb);
|
839
|
+
}
|
840
|
+
/* Now handle all the packets, for real */
|
841
|
+
SLLIST_ITERFOR(&pipeline->requests, &iter) {
|
842
|
+
mc_PACKET *pkt = SLLIST_ITEM(iter.cur, mc_PACKET, slnode);
|
843
|
+
fpl->handler(pipeline->parent, pkt);
|
844
|
+
sllist_iter_remove(&pipeline->requests, &iter);
|
845
|
+
mcreq_packet_handled(pipeline, pkt);
|
846
|
+
}
|
847
|
+
}
|
848
|
+
|
849
|
+
void
|
850
|
+
mcreq_set_fallback_handler(mc_CMDQUEUE *cq, mcreq_fallback_cb handler)
|
851
|
+
{
|
852
|
+
assert(!cq->fallback);
|
853
|
+
cq->fallback = calloc(1, sizeof (mc_FALLBACKPL));
|
854
|
+
mcreq_pipeline_init(cq->fallback);
|
855
|
+
cq->fallback->parent = cq;
|
856
|
+
cq->fallback->index = cq->npipelines;
|
857
|
+
((mc_FALLBACKPL*)cq->fallback)->handler = handler;
|
858
|
+
cq->fallback->flush_start = do_fallback_flush;
|
859
|
+
}
|
860
|
+
|
861
|
+
static void
|
862
|
+
noop_dumpfn(const void *d, unsigned n, FILE *fp) { (void)d;(void)n;(void)fp; }
|
863
|
+
|
864
|
+
#define MCREQ_XFLAGS(X) \
|
865
|
+
X(KEY_NOCOPY) \
|
866
|
+
X(VALUE_NOCOPY) \
|
867
|
+
X(VALUE_IOV) \
|
868
|
+
X(HASVALUE) \
|
869
|
+
X(REQEXT) \
|
870
|
+
X(UFWD) \
|
871
|
+
X(FLUSHED) \
|
872
|
+
X(INVOKED) \
|
873
|
+
X(DETACHED)
|
874
|
+
|
875
|
+
void
|
876
|
+
mcreq_dump_packet(const mc_PACKET *packet, FILE *fp, mcreq_payload_dump_fn dumpfn)
|
877
|
+
{
|
878
|
+
const char *indent = " ";
|
879
|
+
const mc_REQDATA *rdata = MCREQ_PKT_RDATA(packet);
|
880
|
+
|
881
|
+
if (!dumpfn) {
|
882
|
+
dumpfn = noop_dumpfn;
|
883
|
+
}
|
884
|
+
if (!fp) {
|
885
|
+
fp = stderr;
|
886
|
+
}
|
887
|
+
|
888
|
+
fprintf(fp, "Packet @%p\n", (void *)packet);
|
889
|
+
fprintf(fp, "%sOPAQUE: %u\n", indent, (unsigned int)packet->opaque);
|
890
|
+
|
891
|
+
fprintf(fp, "%sPKTFLAGS: 0x%x ", indent, packet->flags);
|
892
|
+
#define X(base) \
|
893
|
+
if (packet->flags & MCREQ_F_##base) { fprintf(fp, "%s, ", #base); }
|
894
|
+
MCREQ_XFLAGS(X)
|
895
|
+
#undef X
|
896
|
+
fprintf(fp, "\n");
|
897
|
+
|
898
|
+
fprintf(fp, "%sKey+Header Size: %u\n", indent, (unsigned int)packet->kh_span.size);
|
899
|
+
fprintf(fp, "%sKey Offset: %u\n", indent, MCREQ_PKT_BASESIZE + packet->extlen);
|
900
|
+
|
901
|
+
|
902
|
+
if (packet->flags & MCREQ_F_HASVALUE) {
|
903
|
+
if (packet->flags & MCREQ_F_VALUE_IOV) {
|
904
|
+
fprintf(fp, "%sValue Length: %u\n", indent,
|
905
|
+
packet->u_value.multi.total_length);
|
906
|
+
|
907
|
+
fprintf(fp, "%sValue IOV: [start=%p, n=%d]\n", indent,
|
908
|
+
(void *)packet->u_value.multi.iov, packet->u_value.multi.niov);
|
909
|
+
} else {
|
910
|
+
if (packet->flags & MCREQ_F_VALUE_NOCOPY) {
|
911
|
+
fprintf(fp, "%sValue is user allocated\n", indent);
|
912
|
+
}
|
913
|
+
fprintf(fp, "%sValue: %p, %u bytes\n", indent,
|
914
|
+
SPAN_BUFFER(&packet->u_value.single), packet->u_value.single.size);
|
915
|
+
}
|
916
|
+
}
|
917
|
+
|
918
|
+
fprintf(fp, "%sRDATA(%s): %p\n", indent,
|
919
|
+
(packet->flags & MCREQ_F_REQEXT) ? "ALLOC" : "EMBEDDED", (void *)rdata);
|
920
|
+
|
921
|
+
indent = " ";
|
922
|
+
fprintf(fp, "%sStart: %lu\n", indent, (unsigned long)rdata->start);
|
923
|
+
fprintf(fp, "%sCookie: %p\n", indent, rdata->cookie);
|
924
|
+
|
925
|
+
indent = " ";
|
926
|
+
fprintf(fp, "%sNEXT: %p\n", indent, (void *)packet->slnode.next);
|
927
|
+
if (dumpfn != noop_dumpfn) {
|
928
|
+
fprintf(fp, "PACKET CONTENTS:\n");
|
929
|
+
}
|
930
|
+
|
931
|
+
fwrite(SPAN_BUFFER(&packet->kh_span), 1, packet->kh_span.size, fp);
|
932
|
+
if (packet->flags & MCREQ_F_HASVALUE) {
|
933
|
+
if (packet->flags & MCREQ_F_VALUE_IOV) {
|
934
|
+
const lcb_IOV *iovs = packet->u_value.multi.iov;
|
935
|
+
unsigned ii, ixmax = packet->u_value.multi.niov;
|
936
|
+
for (ii = 0; ii < ixmax; ii++) {
|
937
|
+
dumpfn(iovs[ii].iov_base, iovs[ii].iov_len, fp);
|
938
|
+
}
|
939
|
+
} else {
|
940
|
+
const nb_SPAN *vspan = &packet->u_value.single;
|
941
|
+
dumpfn(SPAN_BUFFER(vspan), vspan->size, fp);
|
942
|
+
}
|
943
|
+
}
|
944
|
+
}
|
945
|
+
|
946
|
+
void
|
947
|
+
mcreq_dump_chain(const mc_PIPELINE *pipeline, FILE *fp, mcreq_payload_dump_fn dumpfn)
|
948
|
+
{
|
949
|
+
sllist_node *ll;
|
950
|
+
SLLIST_FOREACH(&pipeline->requests, ll) {
|
951
|
+
const mc_PACKET *pkt = SLLIST_ITEM(ll, mc_PACKET, slnode);
|
952
|
+
mcreq_dump_packet(pkt, fp, dumpfn);
|
953
|
+
}
|
954
|
+
}
|