libcouchbase 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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,118 @@
|
|
|
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
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @file
|
|
20
|
+
* libuv integration with libcouchbase
|
|
21
|
+
* @author Mark Nunberg
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @ingroup lcb-io-plugin-api
|
|
26
|
+
* @defgroup lcb-libuv libuv
|
|
27
|
+
* @brief libuv integration
|
|
28
|
+
*
|
|
29
|
+
* @details
|
|
30
|
+
* libuv is a cross platform event framework using a completion-based programming
|
|
31
|
+
* model. Since most distributions do not offer up-to-date libuv binary packages
|
|
32
|
+
* and because libuv is constantly evolving itself, binary packages are not
|
|
33
|
+
* provided. The source code for this plugin is actually shipped with the
|
|
34
|
+
* headers of libcouchbase.
|
|
35
|
+
*
|
|
36
|
+
* If you built libuv together with libcouchbase (and thus there exists a
|
|
37
|
+
* library called `libcouchbase_libuv` then you may simply include this file
|
|
38
|
+
* and initialize the iops structure.
|
|
39
|
+
*
|
|
40
|
+
* Otherwise you should ensure that `<libcouchbase/plugins/io/libuv/plugin-libuv.c>`
|
|
41
|
+
* is compiled into an object, _and_ that the `LCBUV_EMBEDDED_SOURCE` macro
|
|
42
|
+
* is defined for both the compiled object and any code in your application
|
|
43
|
+
* that is using the module, thus:
|
|
44
|
+
*
|
|
45
|
+
* @code{.c}
|
|
46
|
+
* //uv-stub.c
|
|
47
|
+
* #include <libcouchbase/plugins/io/libuv/plugin-libuv.c>
|
|
48
|
+
* @endcode
|
|
49
|
+
*
|
|
50
|
+
* Then, in your application
|
|
51
|
+
* @code{.c}
|
|
52
|
+
* #include <libcouchbase/libuv_io_opts.h>
|
|
53
|
+
*
|
|
54
|
+
* lcb_io_opt_t *io;
|
|
55
|
+
* lcbuv_options_t options;
|
|
56
|
+
* options.v.v0.loop = uv_default_loop();
|
|
57
|
+
* options.v.v0.startsop_noop = 1;
|
|
58
|
+
* lcb_create_libuv_io_opts(0, &io, &options);
|
|
59
|
+
* @endcode
|
|
60
|
+
*
|
|
61
|
+
* And then compile as
|
|
62
|
+
* @code
|
|
63
|
+
* $ gcc -o myapp uv-stub.c main.c -DLCBUV_EMBEDDED_SOURCE
|
|
64
|
+
* @endcode
|
|
65
|
+
*
|
|
66
|
+
* @addtogroup lcb-libuv
|
|
67
|
+
* @{
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
#ifndef LCB_PLUGIN_UV_H
|
|
71
|
+
#define LCB_PLUGIN_UV_H
|
|
72
|
+
#ifdef __cplusplus
|
|
73
|
+
extern "C" {
|
|
74
|
+
#endif
|
|
75
|
+
|
|
76
|
+
#include <libcouchbase/couchbase.h>
|
|
77
|
+
#include <uv.h>
|
|
78
|
+
|
|
79
|
+
#ifdef LCBUV_EMBEDDED_SOURCE
|
|
80
|
+
#define LCBUV_API
|
|
81
|
+
#else
|
|
82
|
+
#define LCBUV_API LIBCOUCHBASE_API
|
|
83
|
+
#endif
|
|
84
|
+
|
|
85
|
+
/**Options passed to the iops constructure. You will most likely want
|
|
86
|
+
* to set the 'startsop_noop' field to true if you are using an async
|
|
87
|
+
* application.*/
|
|
88
|
+
typedef struct lcbuv_options_st {
|
|
89
|
+
int version;
|
|
90
|
+
union {
|
|
91
|
+
struct {
|
|
92
|
+
/** External loop to be used (if not default) */
|
|
93
|
+
uv_loop_t *loop;
|
|
94
|
+
|
|
95
|
+
/** Whether run_event_loop/stop_event_loop should do anything */
|
|
96
|
+
int startsop_noop;
|
|
97
|
+
} v0;
|
|
98
|
+
} v;
|
|
99
|
+
} lcbuv_options_t;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Use this if using an existing uv_loop_t
|
|
103
|
+
* @param version Set this to `0`
|
|
104
|
+
* @param [out] io a pointer to an io pointer. Will be populated on success
|
|
105
|
+
* @param options the options to be passed. From libcouchbase this is a
|
|
106
|
+
* `void*` parameter.
|
|
107
|
+
*/
|
|
108
|
+
LCBUV_API
|
|
109
|
+
lcb_error_t lcb_create_libuv_io_opts(int version,
|
|
110
|
+
lcb_io_opt_t *io,
|
|
111
|
+
lcbuv_options_t *options);
|
|
112
|
+
|
|
113
|
+
#ifdef __cplusplus
|
|
114
|
+
}
|
|
115
|
+
#endif
|
|
116
|
+
#endif
|
|
117
|
+
|
|
118
|
+
/**@}*/
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
|
|
18
|
+
#ifndef LCBUV_PLUGIN_INTERNAL_H
|
|
19
|
+
#define LCBUV_PLUGIN_INTERNAL_H
|
|
20
|
+
|
|
21
|
+
#include <libcouchbase/couchbase.h>
|
|
22
|
+
#include <uv.h>
|
|
23
|
+
|
|
24
|
+
#include <errno.h>
|
|
25
|
+
#include <assert.h>
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
#include <stdlib.h>
|
|
28
|
+
#include <string.h>
|
|
29
|
+
#include <sys/types.h>
|
|
30
|
+
|
|
31
|
+
#include "libuv_compat.h"
|
|
32
|
+
|
|
33
|
+
#ifdef LCBUV_EMBEDDED_SOURCE
|
|
34
|
+
#include <libcouchbase/libuv_io_opts.h>
|
|
35
|
+
#else
|
|
36
|
+
/** Load definitions from inside */
|
|
37
|
+
#include "libuv_io_opts.h"
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
typedef void (*v0_callback_t)(lcb_socket_t, short, void *);
|
|
41
|
+
typedef void (*generic_callback_t)(void);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* These structures come about the limitation that with -Werror -Wextra
|
|
46
|
+
* compilation fails because strictly speaking, a function pointer isn't
|
|
47
|
+
* convertible to a normal pointer.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Macro - sometimes we might want to use the ->data field?
|
|
52
|
+
*/
|
|
53
|
+
#define CbREQ(mr) (mr)->callback
|
|
54
|
+
typedef struct {
|
|
55
|
+
uv_tcp_t t;
|
|
56
|
+
lcb_ioC_read2_callback callback;
|
|
57
|
+
} my_tcp_t;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Wrapper for lcb_sockdata_t
|
|
61
|
+
*/
|
|
62
|
+
typedef struct {
|
|
63
|
+
lcb_sockdata_t base;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* UV tcp handle. This is also a uv_stream_t.
|
|
67
|
+
* ->data field contains the read callback
|
|
68
|
+
*/
|
|
69
|
+
my_tcp_t tcp;
|
|
70
|
+
|
|
71
|
+
/** Reference count */
|
|
72
|
+
unsigned int refcount;
|
|
73
|
+
|
|
74
|
+
/** Flag indicating whether uv_close has already been called on the handle */
|
|
75
|
+
unsigned char uv_close_called;
|
|
76
|
+
|
|
77
|
+
lcb_IOV iov;
|
|
78
|
+
void *rdarg;
|
|
79
|
+
|
|
80
|
+
struct {
|
|
81
|
+
int read;
|
|
82
|
+
int write;
|
|
83
|
+
} pending;
|
|
84
|
+
|
|
85
|
+
} my_sockdata_t;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
typedef struct {
|
|
89
|
+
uv_write_t w;
|
|
90
|
+
lcb_ioC_write2_callback callback;
|
|
91
|
+
my_sockdata_t *sock;
|
|
92
|
+
} my_write_t;
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
typedef struct {
|
|
96
|
+
struct lcb_io_opt_st base;
|
|
97
|
+
uv_loop_t *loop;
|
|
98
|
+
|
|
99
|
+
/** Refcount. When this hits zero we free this */
|
|
100
|
+
unsigned int iops_refcount;
|
|
101
|
+
|
|
102
|
+
/** Whether using a user-initiated loop */
|
|
103
|
+
int external_loop;
|
|
104
|
+
|
|
105
|
+
/** whether start/stop are noops */
|
|
106
|
+
int startstop_noop;
|
|
107
|
+
|
|
108
|
+
/** for 0.8 only, whether to stop */
|
|
109
|
+
int do_stop;
|
|
110
|
+
} my_iops_t;
|
|
111
|
+
|
|
112
|
+
typedef struct {
|
|
113
|
+
uv_timer_t uvt;
|
|
114
|
+
v0_callback_t callback;
|
|
115
|
+
void *cb_arg;
|
|
116
|
+
my_iops_t *parent;
|
|
117
|
+
} my_timer_t;
|
|
118
|
+
|
|
119
|
+
typedef struct {
|
|
120
|
+
union {
|
|
121
|
+
uv_connect_t conn;
|
|
122
|
+
uv_idle_t idle;
|
|
123
|
+
} uvreq;
|
|
124
|
+
|
|
125
|
+
union {
|
|
126
|
+
lcb_io_connect_cb conn;
|
|
127
|
+
generic_callback_t cb_;
|
|
128
|
+
} cb;
|
|
129
|
+
|
|
130
|
+
my_sockdata_t *socket;
|
|
131
|
+
} my_uvreq_t;
|
|
132
|
+
|
|
133
|
+
/******************************************************************************
|
|
134
|
+
******************************************************************************
|
|
135
|
+
** Common Macros **
|
|
136
|
+
******************************************************************************
|
|
137
|
+
******************************************************************************/
|
|
138
|
+
#define PTR_FROM_FIELD(t, p, fld) ((t*)(void*)((char*)p-(offsetof(t, fld))))
|
|
139
|
+
|
|
140
|
+
#define incref_iops(io) (io)->iops_refcount++
|
|
141
|
+
|
|
142
|
+
#ifdef _WIN32
|
|
143
|
+
typedef ULONG lcb_uvbuf_len_t;
|
|
144
|
+
#else
|
|
145
|
+
typedef size_t lcb_uvbuf_len_t;
|
|
146
|
+
#endif
|
|
147
|
+
|
|
148
|
+
#endif
|
|
@@ -0,0 +1,648 @@
|
|
|
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
|
+
|
|
18
|
+
#include "plugin-internal.h"
|
|
19
|
+
|
|
20
|
+
static my_uvreq_t *alloc_uvreq(my_sockdata_t *sock, generic_callback_t callback);
|
|
21
|
+
static void set_last_error(my_iops_t *io, int error);
|
|
22
|
+
static void socket_closed_callback(uv_handle_t *handle);
|
|
23
|
+
|
|
24
|
+
static void wire_iops2(int version,
|
|
25
|
+
lcb_loop_procs *loop,
|
|
26
|
+
lcb_timer_procs *timer,
|
|
27
|
+
lcb_bsd_procs *bsd,
|
|
28
|
+
lcb_ev_procs *ev,
|
|
29
|
+
lcb_completion_procs *iocp,
|
|
30
|
+
lcb_iomodel_t *model);
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
static void decref_iops(lcb_io_opt_t iobase)
|
|
34
|
+
{
|
|
35
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
36
|
+
lcb_assert(io->iops_refcount);
|
|
37
|
+
if (--io->iops_refcount) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
memset(io, 0xff, sizeof(*io));
|
|
42
|
+
free(io);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static void iops_lcb_dtor(lcb_io_opt_t iobase)
|
|
46
|
+
{
|
|
47
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
48
|
+
if (io->startstop_noop) {
|
|
49
|
+
decref_iops(iobase);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
while (io->iops_refcount > 1) {
|
|
54
|
+
UVC_RUN_ONCE(io->loop);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (io->external_loop == 0) {
|
|
58
|
+
uv_loop_delete(io->loop);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
decref_iops(iobase);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/******************************************************************************
|
|
65
|
+
******************************************************************************
|
|
66
|
+
** Event Loop Functions **
|
|
67
|
+
******************************************************************************
|
|
68
|
+
******************************************************************************/
|
|
69
|
+
|
|
70
|
+
#if UV_VERSION < 0x000900
|
|
71
|
+
static void do_run_loop(my_iops_t *io)
|
|
72
|
+
{
|
|
73
|
+
while (uv_run_once(io->loop) && io->do_stop == 0) {
|
|
74
|
+
/* nothing */
|
|
75
|
+
}
|
|
76
|
+
io->do_stop = 0;
|
|
77
|
+
}
|
|
78
|
+
static void do_stop_loop(my_iops_t *io)
|
|
79
|
+
{
|
|
80
|
+
io->do_stop = 1;
|
|
81
|
+
}
|
|
82
|
+
#else
|
|
83
|
+
static void do_run_loop(my_iops_t *io) {
|
|
84
|
+
uv_run(io->loop, UV_RUN_DEFAULT);
|
|
85
|
+
}
|
|
86
|
+
static void do_stop_loop(my_iops_t *io)
|
|
87
|
+
{
|
|
88
|
+
uv_stop(io->loop);
|
|
89
|
+
}
|
|
90
|
+
#endif
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
static void run_event_loop(lcb_io_opt_t iobase)
|
|
94
|
+
{
|
|
95
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
96
|
+
|
|
97
|
+
if (!io->startstop_noop) {
|
|
98
|
+
do_run_loop(io);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static void tick_event_loop(lcb_io_opt_t iobase)
|
|
103
|
+
{
|
|
104
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
105
|
+
if (!io->startstop_noop) {
|
|
106
|
+
#if UV_VERSION < 0x000900
|
|
107
|
+
uv_run_once(io->loop);
|
|
108
|
+
io->do_stop = 0;
|
|
109
|
+
#else
|
|
110
|
+
uv_run(io->loop, UV_RUN_NOWAIT);
|
|
111
|
+
#endif
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static void stop_event_loop(lcb_io_opt_t iobase)
|
|
116
|
+
{
|
|
117
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
118
|
+
if (!io->startstop_noop) {
|
|
119
|
+
do_stop_loop(io);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
LCBUV_API
|
|
124
|
+
lcb_error_t lcb_create_libuv_io_opts(int version,
|
|
125
|
+
lcb_io_opt_t *io,
|
|
126
|
+
lcbuv_options_t *options)
|
|
127
|
+
{
|
|
128
|
+
lcb_io_opt_t iop;
|
|
129
|
+
uv_loop_t *loop = NULL;
|
|
130
|
+
my_iops_t *ret;
|
|
131
|
+
|
|
132
|
+
if (version != 0) {
|
|
133
|
+
return LCB_PLUGIN_VERSION_MISMATCH;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
#ifdef _WIN32
|
|
137
|
+
{
|
|
138
|
+
/** UV unloading on Windows doesn't work well */
|
|
139
|
+
HMODULE module;
|
|
140
|
+
/* We need to provide a symbol */
|
|
141
|
+
static int dummy;
|
|
142
|
+
BOOL result;
|
|
143
|
+
result = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
|
|
144
|
+
GET_MODULE_HANDLE_EX_FLAG_PIN,
|
|
145
|
+
(LPCSTR)&dummy,
|
|
146
|
+
&module);
|
|
147
|
+
if (!result) {
|
|
148
|
+
return LCB_EINTERNAL;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
#endif
|
|
152
|
+
|
|
153
|
+
ret = calloc(1, sizeof(*ret));
|
|
154
|
+
|
|
155
|
+
if (!ret) {
|
|
156
|
+
return LCB_CLIENT_ENOMEM;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
iop = &ret->base;
|
|
160
|
+
iop->version = 2;
|
|
161
|
+
iop->destructor = iops_lcb_dtor;
|
|
162
|
+
iop->v.v2.get_procs = wire_iops2;
|
|
163
|
+
|
|
164
|
+
ret->iops_refcount = 1;
|
|
165
|
+
|
|
166
|
+
*io = iop;
|
|
167
|
+
if (options) {
|
|
168
|
+
if (options->v.v0.loop) {
|
|
169
|
+
ret->external_loop = 1;
|
|
170
|
+
loop = options->v.v0.loop;
|
|
171
|
+
}
|
|
172
|
+
ret->startstop_noop = options->v.v0.startsop_noop;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!loop) {
|
|
176
|
+
loop = uv_loop_new();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
ret->loop = loop;
|
|
180
|
+
|
|
181
|
+
return LCB_SUCCESS;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#define SOCK_INCR_PENDING(s, fld) (s)->pending.fld++
|
|
185
|
+
#define SOCK_DECR_PENDING(s, fld) (s)->pending.fld--
|
|
186
|
+
|
|
187
|
+
#ifdef DEBUG
|
|
188
|
+
static void sock_dump_pending(my_sockdata_t *sock)
|
|
189
|
+
{
|
|
190
|
+
printf("Socket %p:\n", (void *)sock);
|
|
191
|
+
printf("\tRead: %d\n", sock->pending.read);
|
|
192
|
+
printf("\tWrite: %d\n", sock->pending.write);
|
|
193
|
+
}
|
|
194
|
+
#endif
|
|
195
|
+
|
|
196
|
+
static void sock_do_uv_close(my_sockdata_t *sock)
|
|
197
|
+
{
|
|
198
|
+
if (!sock->uv_close_called) {
|
|
199
|
+
sock->uv_close_called = 1;
|
|
200
|
+
uv_close((uv_handle_t *)&sock->tcp, socket_closed_callback);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
static void decref_sock(my_sockdata_t *sock)
|
|
205
|
+
{
|
|
206
|
+
lcb_assert(sock->refcount);
|
|
207
|
+
|
|
208
|
+
if (--sock->refcount) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
sock_do_uv_close(sock);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#define incref_sock(sd) (sd)->refcount++
|
|
215
|
+
|
|
216
|
+
/******************************************************************************
|
|
217
|
+
******************************************************************************
|
|
218
|
+
** Socket Functions **
|
|
219
|
+
******************************************************************************
|
|
220
|
+
******************************************************************************/
|
|
221
|
+
static lcb_sockdata_t *create_socket(lcb_io_opt_t iobase,
|
|
222
|
+
int domain,
|
|
223
|
+
int type,
|
|
224
|
+
int protocol)
|
|
225
|
+
{
|
|
226
|
+
my_sockdata_t *ret;
|
|
227
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
228
|
+
|
|
229
|
+
ret = calloc(1, sizeof(*ret));
|
|
230
|
+
if (!ret) {
|
|
231
|
+
return NULL;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
uv_tcp_init(io->loop, &ret->tcp.t);
|
|
235
|
+
|
|
236
|
+
incref_iops(io);
|
|
237
|
+
incref_sock(ret);
|
|
238
|
+
|
|
239
|
+
set_last_error(io, 0);
|
|
240
|
+
|
|
241
|
+
(void)domain;
|
|
242
|
+
(void)type;
|
|
243
|
+
(void)protocol;
|
|
244
|
+
|
|
245
|
+
return (lcb_sockdata_t *)ret;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* This one is called from uv_close
|
|
250
|
+
*/
|
|
251
|
+
static void socket_closed_callback(uv_handle_t *handle)
|
|
252
|
+
{
|
|
253
|
+
my_sockdata_t *sock = PTR_FROM_FIELD(my_sockdata_t, handle, tcp);
|
|
254
|
+
my_iops_t *io = (my_iops_t *)sock->base.parent;
|
|
255
|
+
|
|
256
|
+
if (sock->pending.read) {
|
|
257
|
+
CbREQ(&sock->tcp)(&sock->base, -1, sock->rdarg);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
memset(sock, 0xEE, sizeof(*sock));
|
|
261
|
+
free(sock);
|
|
262
|
+
|
|
263
|
+
decref_iops(&io->base);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
static unsigned int close_socket(lcb_io_opt_t iobase, lcb_sockdata_t *sockbase)
|
|
268
|
+
{
|
|
269
|
+
my_sockdata_t *sock = (my_sockdata_t *)sockbase;
|
|
270
|
+
sock->uv_close_called = 1;
|
|
271
|
+
uv_close((uv_handle_t *)&sock->tcp, socket_closed_callback);
|
|
272
|
+
(void)iobase;
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
static int cntl_socket(lcb_io_opt_t iobase, lcb_sockdata_t *sockbase,
|
|
277
|
+
int mode, int option, void *arg)
|
|
278
|
+
{
|
|
279
|
+
my_sockdata_t *sd = (my_sockdata_t *)sockbase;
|
|
280
|
+
int rv;
|
|
281
|
+
|
|
282
|
+
switch (option) {
|
|
283
|
+
case LCB_IO_CNTL_TCP_NODELAY:
|
|
284
|
+
if (mode == LCB_IO_CNTL_SET) {
|
|
285
|
+
rv = uv_tcp_nodelay(&sd->tcp.t, *(int *)arg);
|
|
286
|
+
if (rv != 0) {
|
|
287
|
+
set_last_error((my_iops_t*)iobase, rv);
|
|
288
|
+
}
|
|
289
|
+
return rv;
|
|
290
|
+
} else {
|
|
291
|
+
LCB_IOPS_ERRNO(iobase) = ENOTSUP;
|
|
292
|
+
return -1;
|
|
293
|
+
}
|
|
294
|
+
default:
|
|
295
|
+
LCB_IOPS_ERRNO(iobase) = ENOTSUP;
|
|
296
|
+
return -1;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
/******************************************************************************
|
|
302
|
+
******************************************************************************
|
|
303
|
+
** Connection Functions **
|
|
304
|
+
******************************************************************************
|
|
305
|
+
******************************************************************************/
|
|
306
|
+
static void connect_callback(uv_connect_t *req, int status)
|
|
307
|
+
{
|
|
308
|
+
my_uvreq_t *uvr = (my_uvreq_t *)req;
|
|
309
|
+
|
|
310
|
+
set_last_error((my_iops_t *)uvr->socket->base.parent, status);
|
|
311
|
+
|
|
312
|
+
if (uvr->cb.conn) {
|
|
313
|
+
uvr->cb.conn(&uvr->socket->base, status);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
decref_sock(uvr->socket);
|
|
317
|
+
free(uvr);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
static int start_connect(lcb_io_opt_t iobase,
|
|
321
|
+
lcb_sockdata_t *sockbase,
|
|
322
|
+
const struct sockaddr *name,
|
|
323
|
+
unsigned int namelen,
|
|
324
|
+
lcb_io_connect_cb callback)
|
|
325
|
+
{
|
|
326
|
+
my_sockdata_t *sock = (my_sockdata_t *)sockbase;
|
|
327
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
328
|
+
my_uvreq_t *uvr;
|
|
329
|
+
int ret;
|
|
330
|
+
int err_is_set = 0;
|
|
331
|
+
|
|
332
|
+
uvr = alloc_uvreq(sock, (generic_callback_t)callback);
|
|
333
|
+
if (!uvr) {
|
|
334
|
+
return -1;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (namelen == sizeof(struct sockaddr_in)) {
|
|
338
|
+
ret = UVC_TCP_CONNECT(&uvr->uvreq.conn,
|
|
339
|
+
&sock->tcp.t,
|
|
340
|
+
name,
|
|
341
|
+
connect_callback);
|
|
342
|
+
|
|
343
|
+
} else if (namelen == sizeof(struct sockaddr_in6)) {
|
|
344
|
+
ret = UVC_TCP_CONNECT6(&uvr->uvreq.conn,
|
|
345
|
+
&sock->tcp.t,
|
|
346
|
+
name,
|
|
347
|
+
connect_callback);
|
|
348
|
+
|
|
349
|
+
} else {
|
|
350
|
+
io->base.v.v1.error = EINVAL;
|
|
351
|
+
ret = -1;
|
|
352
|
+
err_is_set = 1;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (ret) {
|
|
356
|
+
if (!err_is_set) {
|
|
357
|
+
set_last_error(io, ret);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
free(uvr);
|
|
361
|
+
|
|
362
|
+
} else {
|
|
363
|
+
incref_sock(sock);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return ret;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/******************************************************************************
|
|
370
|
+
******************************************************************************
|
|
371
|
+
** Write Functions **
|
|
372
|
+
******************************************************************************
|
|
373
|
+
******************************************************************************/
|
|
374
|
+
static void write2_callback(uv_write_t *req, int status)
|
|
375
|
+
{
|
|
376
|
+
my_write_t *mw = (my_write_t *)req;
|
|
377
|
+
my_sockdata_t *sock = mw->sock;
|
|
378
|
+
|
|
379
|
+
if (status != 0) {
|
|
380
|
+
set_last_error((my_iops_t *)sock->base.parent, status);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
mw->callback(&sock->base, status, mw->w.data);
|
|
384
|
+
free(mw);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
static int start_write2(lcb_io_opt_t iobase,
|
|
388
|
+
lcb_sockdata_t *sockbase,
|
|
389
|
+
struct lcb_iovec_st *iov,
|
|
390
|
+
lcb_size_t niov,
|
|
391
|
+
void *uarg,
|
|
392
|
+
lcb_ioC_write2_callback callback)
|
|
393
|
+
{
|
|
394
|
+
my_write_t *w;
|
|
395
|
+
my_sockdata_t *sd = (my_sockdata_t *)sockbase;
|
|
396
|
+
int ret;
|
|
397
|
+
|
|
398
|
+
w = calloc(1, sizeof(*w));
|
|
399
|
+
w->w.data = uarg;
|
|
400
|
+
w->callback = callback;
|
|
401
|
+
w->sock = sd;
|
|
402
|
+
|
|
403
|
+
ret = uv_write(&w->w, (uv_stream_t *)&sd->tcp,
|
|
404
|
+
(uv_buf_t *)iov,
|
|
405
|
+
niov,
|
|
406
|
+
write2_callback);
|
|
407
|
+
|
|
408
|
+
if (ret != 0) {
|
|
409
|
+
free(w);
|
|
410
|
+
set_last_error((my_iops_t *)iobase, -1);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return ret;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/******************************************************************************
|
|
417
|
+
******************************************************************************
|
|
418
|
+
** Read Functions **
|
|
419
|
+
******************************************************************************
|
|
420
|
+
******************************************************************************/
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Currently we support a single IOV. In theory while we could support
|
|
424
|
+
* multiple IOVs, two problems arise:
|
|
425
|
+
*
|
|
426
|
+
* (1) Because UV does not guarantee that it'll utilize the first IOV completely
|
|
427
|
+
* we may end up having a gap of unused space between IOVs. This may be
|
|
428
|
+
* resolved by keeping an offset into the last-returned IOV and then
|
|
429
|
+
* determining how much of this data was actually populated by UV itself.
|
|
430
|
+
*
|
|
431
|
+
* (2) In the event of an error, UV gives us "Undefined" behavior if we try
|
|
432
|
+
* to utilize the socket again. The IOPS policy dictates that we deliver
|
|
433
|
+
* any outstanding data to libcouchbase and _then_ deliver the pending
|
|
434
|
+
* error. If we are forced to do this all in a single go, we'd be forced
|
|
435
|
+
* to set up an 'async handle' to deliver the pending error, complicating
|
|
436
|
+
* our code paths.
|
|
437
|
+
*/
|
|
438
|
+
|
|
439
|
+
static UVC_ALLOC_CB(alloc_cb)
|
|
440
|
+
{
|
|
441
|
+
UVC_ALLOC_CB_VARS()
|
|
442
|
+
|
|
443
|
+
my_sockdata_t *sock = PTR_FROM_FIELD(my_sockdata_t, handle, tcp);
|
|
444
|
+
buf->base = sock->iov.iov_base;
|
|
445
|
+
buf->len = sock->iov.iov_len;
|
|
446
|
+
|
|
447
|
+
(void)suggested_size;
|
|
448
|
+
UVC_ALLOC_CB_RETURN();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
static UVC_READ_CB(read_cb)
|
|
452
|
+
{
|
|
453
|
+
UVC_READ_CB_VARS()
|
|
454
|
+
|
|
455
|
+
my_tcp_t *mt = (my_tcp_t *)stream;
|
|
456
|
+
my_sockdata_t *sock = PTR_FROM_FIELD(my_sockdata_t, mt, tcp);
|
|
457
|
+
my_iops_t *io = (my_iops_t *)sock->base.parent;
|
|
458
|
+
lcb_ioC_read2_callback callback = CbREQ(mt);
|
|
459
|
+
|
|
460
|
+
if (nread == 0) {
|
|
461
|
+
/* we have a fixed IOV between requests, so just retry again */
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* XXX:
|
|
467
|
+
* For multi-IOV support, we would require a counter to determine if this
|
|
468
|
+
* EAGAIN is spurious (i.e. no previous data in buffer), or actual. In
|
|
469
|
+
* the case of the former, we'd retry -- but in the latter it is a signal
|
|
470
|
+
* that there is no more pending data within the socket buffer AND we have
|
|
471
|
+
* outstanding data to deliver back to the caller.
|
|
472
|
+
*/
|
|
473
|
+
SOCK_DECR_PENDING(sock, read);
|
|
474
|
+
uv_read_stop(stream);
|
|
475
|
+
CbREQ(mt) = NULL;
|
|
476
|
+
|
|
477
|
+
if (nread < 0) {
|
|
478
|
+
set_last_error(io, uvc_last_errno(io->loop, nread));
|
|
479
|
+
if (uvc_is_eof(io->loop, nread)) {
|
|
480
|
+
nread = 0;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
callback(&sock->base, nread, sock->rdarg);
|
|
484
|
+
decref_sock(sock);
|
|
485
|
+
(void)buf;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
static int start_read(lcb_io_opt_t iobase,
|
|
489
|
+
lcb_sockdata_t *sockbase,
|
|
490
|
+
lcb_IOV *iov,
|
|
491
|
+
lcb_size_t niov,
|
|
492
|
+
void *uarg,
|
|
493
|
+
lcb_ioC_read2_callback callback)
|
|
494
|
+
{
|
|
495
|
+
my_sockdata_t *sock = (my_sockdata_t *)sockbase;
|
|
496
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
497
|
+
int ret;
|
|
498
|
+
|
|
499
|
+
sock->iov = *iov;
|
|
500
|
+
sock->rdarg = uarg;
|
|
501
|
+
sock->tcp.callback = callback;
|
|
502
|
+
|
|
503
|
+
ret = uv_read_start((uv_stream_t *)&sock->tcp.t, alloc_cb, read_cb);
|
|
504
|
+
set_last_error(io, ret);
|
|
505
|
+
|
|
506
|
+
if (ret == 0) {
|
|
507
|
+
SOCK_INCR_PENDING(sock, read);
|
|
508
|
+
incref_sock(sock);
|
|
509
|
+
}
|
|
510
|
+
return ret;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
static int get_nameinfo(lcb_io_opt_t iobase,
|
|
514
|
+
lcb_sockdata_t *sockbase,
|
|
515
|
+
struct lcb_nameinfo_st *ni)
|
|
516
|
+
{
|
|
517
|
+
my_sockdata_t *sock = (my_sockdata_t *)sockbase;
|
|
518
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
519
|
+
uv_tcp_getpeername(&sock->tcp.t, ni->remote.name, ni->remote.len);
|
|
520
|
+
uv_tcp_getsockname(&sock->tcp.t, ni->local.name, ni->local.len);
|
|
521
|
+
|
|
522
|
+
(void)io;
|
|
523
|
+
return 0;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/******************************************************************************
|
|
527
|
+
******************************************************************************
|
|
528
|
+
** Timer Functions **
|
|
529
|
+
** There are just copied from the old couchnode I/O code **
|
|
530
|
+
******************************************************************************
|
|
531
|
+
******************************************************************************/
|
|
532
|
+
static UVC_TIMER_CB(timer_cb)
|
|
533
|
+
{
|
|
534
|
+
my_timer_t *mytimer = (my_timer_t *)timer;
|
|
535
|
+
if (mytimer->callback) {
|
|
536
|
+
mytimer->callback(-1, 0, mytimer->cb_arg);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
static void *create_timer(lcb_io_opt_t iobase)
|
|
541
|
+
{
|
|
542
|
+
my_iops_t *io = (my_iops_t *)iobase;
|
|
543
|
+
my_timer_t *timer = calloc(1, sizeof(*timer));
|
|
544
|
+
if (!timer) {
|
|
545
|
+
return NULL;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
timer->parent = io;
|
|
549
|
+
incref_iops(io);
|
|
550
|
+
uv_timer_init(io->loop, &timer->uvt);
|
|
551
|
+
|
|
552
|
+
return timer;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
static int update_timer(lcb_io_opt_t iobase,
|
|
556
|
+
void *timer_opaque,
|
|
557
|
+
lcb_uint32_t usec,
|
|
558
|
+
void *cbdata,
|
|
559
|
+
v0_callback_t callback)
|
|
560
|
+
{
|
|
561
|
+
my_timer_t *timer = (my_timer_t *)timer_opaque;
|
|
562
|
+
|
|
563
|
+
timer->callback = callback;
|
|
564
|
+
timer->cb_arg = cbdata;
|
|
565
|
+
|
|
566
|
+
(void)iobase;
|
|
567
|
+
|
|
568
|
+
return uv_timer_start(&timer->uvt, timer_cb, usec / 1000, 0);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
static void delete_timer(lcb_io_opt_t iobase, void *timer_opaque)
|
|
572
|
+
{
|
|
573
|
+
my_timer_t *timer = (my_timer_t *)timer_opaque;
|
|
574
|
+
|
|
575
|
+
uv_timer_stop(&timer->uvt);
|
|
576
|
+
timer->callback = NULL;
|
|
577
|
+
|
|
578
|
+
(void)iobase;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
static void timer_close_cb(uv_handle_t *handle)
|
|
582
|
+
{
|
|
583
|
+
my_timer_t *timer = (my_timer_t *)handle;
|
|
584
|
+
decref_iops(&timer->parent->base);
|
|
585
|
+
memset(timer, 0xff, sizeof(*timer));
|
|
586
|
+
free(timer);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
static void destroy_timer(lcb_io_opt_t io, void *timer_opaque)
|
|
590
|
+
{
|
|
591
|
+
delete_timer(io, timer_opaque);
|
|
592
|
+
uv_close((uv_handle_t *)timer_opaque, timer_close_cb);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
static my_uvreq_t *alloc_uvreq(my_sockdata_t *sock, generic_callback_t callback)
|
|
596
|
+
{
|
|
597
|
+
my_uvreq_t *ret = calloc(1, sizeof(*ret));
|
|
598
|
+
if (!ret) {
|
|
599
|
+
sock->base.parent->v.v1.error = ENOMEM;
|
|
600
|
+
return NULL;
|
|
601
|
+
}
|
|
602
|
+
ret->socket = sock;
|
|
603
|
+
ret->cb.cb_ = callback;
|
|
604
|
+
return ret;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
static void set_last_error(my_iops_t *io, int error)
|
|
609
|
+
{
|
|
610
|
+
io->base.v.v1.error = uvc_last_errno(io->loop, error);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
static void wire_iops2(int version,
|
|
614
|
+
lcb_loop_procs *loop,
|
|
615
|
+
lcb_timer_procs *timer,
|
|
616
|
+
lcb_bsd_procs *bsd,
|
|
617
|
+
lcb_ev_procs *ev,
|
|
618
|
+
lcb_completion_procs *iocp,
|
|
619
|
+
lcb_iomodel_t *model)
|
|
620
|
+
{
|
|
621
|
+
*model = LCB_IOMODEL_COMPLETION;
|
|
622
|
+
loop->start = run_event_loop;
|
|
623
|
+
loop->stop = stop_event_loop;
|
|
624
|
+
loop->tick = tick_event_loop;
|
|
625
|
+
|
|
626
|
+
timer->create = create_timer;
|
|
627
|
+
timer->cancel = delete_timer;
|
|
628
|
+
timer->schedule = update_timer;
|
|
629
|
+
timer->destroy = destroy_timer;
|
|
630
|
+
|
|
631
|
+
iocp->close = close_socket;
|
|
632
|
+
iocp->socket = create_socket;
|
|
633
|
+
iocp->connect = start_connect;
|
|
634
|
+
iocp->nameinfo = get_nameinfo;
|
|
635
|
+
iocp->read2 = start_read;
|
|
636
|
+
iocp->write2 = start_write2;
|
|
637
|
+
iocp->cntl = cntl_socket;
|
|
638
|
+
|
|
639
|
+
/** Stuff we don't use */
|
|
640
|
+
iocp->write = NULL;
|
|
641
|
+
iocp->wballoc = NULL;
|
|
642
|
+
iocp->wbfree = NULL;
|
|
643
|
+
iocp->serve = NULL;
|
|
644
|
+
|
|
645
|
+
(void)bsd;
|
|
646
|
+
(void)version;
|
|
647
|
+
(void)ev;
|
|
648
|
+
}
|