diff --git a/CMakeLists.txt b/CMakeLists.txt index b05ea7165..9df8e0571 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,3 +248,8 @@ TNTCXX_TEST(NAME SchemalessExample TYPE other SOURCES examples/Schemaless.cpp LIBRARIES ${COMMON_LIB} ) + +TNTCXX_TEST(NAME LinkTest TYPE other + SOURCES test/LinkTest/Main.cpp test/LinkTest/Secondary.cpp + LIBRARIES ${COMMON_LIB} +) diff --git a/src/Client/Scramble.hpp b/src/Client/Scramble.hpp index 32a90eff6..fbb8a451e 100644 --- a/src/Client/Scramble.hpp +++ b/src/Client/Scramble.hpp @@ -36,7 +36,7 @@ namespace tnt { -tnt::Sha1_type +inline tnt::Sha1_type scramble(std::string_view password, const char *salt) { Sha1_type hash1 = sha1(password); diff --git a/src/Client/Stream.hpp b/src/Client/Stream.hpp index e3b1d5100..6286cbbad 100644 --- a/src/Client/Stream.hpp +++ b/src/Client/Stream.hpp @@ -181,7 +181,7 @@ class Stream { ////////////////////////// Implementation ////////////////////////// ///////////////////////////////////////////////////////////////////// -std::ostream & +inline std::ostream & operator<<(std::ostream &strm, enum StreamTransport transport) { if (transport == STREAM_PLAIN) @@ -192,7 +192,7 @@ operator<<(std::ostream &strm, enum StreamTransport transport) return strm << "unknown transport"; } -std::ostream & +inline std::ostream & operator<<(std::ostream &strm, const ConnectOptions &opts) { strm << opts.address; @@ -203,7 +203,7 @@ operator<<(std::ostream &strm, const ConnectOptions &opts) return strm; } -int +inline int Stream::set_status(uint32_t st) { if (st & SS_READINESS_STATUS) @@ -219,7 +219,7 @@ Stream::set_status(uint32_t st) return 0; } -int +inline int Stream::remove_status(uint32_t st) { assert(!(st & SS_READINESS_STATUS)); diff --git a/src/Client/UnixPlainStream.hpp b/src/Client/UnixPlainStream.hpp index 25d8ccb8d..97056e686 100644 --- a/src/Client/UnixPlainStream.hpp +++ b/src/Client/UnixPlainStream.hpp @@ -71,7 +71,7 @@ class UnixPlainStream : public UnixStream { ////////////////////////// Implementation ////////////////////////// ///////////////////////////////////////////////////////////////////// -int +inline int UnixPlainStream::connect(const ConnectOptions &opts) { if (opts.transport != STREAM_PLAIN) @@ -81,7 +81,7 @@ UnixPlainStream::connect(const ConnectOptions &opts) } namespace internal { -struct msghdr +inline struct msghdr create_msghdr(struct iovec *iov, size_t iov_count) { struct msghdr msg{}; @@ -91,7 +91,7 @@ create_msghdr(struct iovec *iov, size_t iov_count) } } // namespace internal -ssize_t +inline ssize_t UnixPlainStream::send(struct iovec *iov, size_t iov_count) { if (!(has_status(SS_ESTABLISHED))) { @@ -120,7 +120,7 @@ UnixPlainStream::send(struct iovec *iov, size_t iov_count) } } -ssize_t +inline ssize_t UnixPlainStream::recv(struct iovec *iov, size_t iov_count) { if (!(has_status(SS_ESTABLISHED))) { diff --git a/src/Client/UnixStream.hpp b/src/Client/UnixStream.hpp index 3caaca69c..5e8bc589b 100644 --- a/src/Client/UnixStream.hpp +++ b/src/Client/UnixStream.hpp @@ -142,7 +142,7 @@ UnixStream::tell(StreamStatus st, const char *file, int line, return 0; } -int +inline int UnixStream::check_pending() { assert(has_status(SS_CONNECT_PENDING)); @@ -154,7 +154,7 @@ UnixStream::check_pending() return US_DIE("Failed to connect", strerror(rc == 0 ? err : errno)); } -int +inline int UnixStream::connect(const ConnectOptions &opts_arg) { if (!has_status(SS_DEAD)) @@ -217,12 +217,14 @@ UnixStream::connect(const ConnectOptions &opts_arg) return US_DIE("Failed to connect"); } +inline UnixStream::~UnixStream() noexcept { close(); } -void UnixStream::close() +inline void +UnixStream::close() { if (fd >= 0) { if (::close(fd) == 0) diff --git a/src/Utils/AddrInfo.hpp b/src/Utils/AddrInfo.hpp index 297d6c7f8..20a65775b 100644 --- a/src/Utils/AddrInfo.hpp +++ b/src/Utils/AddrInfo.hpp @@ -91,6 +91,7 @@ AddrInfo::~AddrInfo() noexcept freeaddrinfo(infos); } +inline AddrInfo::AddrInfo(const std::string &addr, const std::string &service) { resolve(addr, service); diff --git a/src/Utils/Sha1.hpp b/src/Utils/Sha1.hpp index ca1e7a5af..de6bd4bab 100644 --- a/src/Utils/Sha1.hpp +++ b/src/Utils/Sha1.hpp @@ -71,6 +71,7 @@ inline void sha1_xor(Sha1_type &a, const Sha1_type &b); ////////////////////////// Implementation ////////////////////////// ///////////////////////////////////////////////////////////////////// +inline Sha1Calc::Sha1Calc() { SHA1Init(&ctx); diff --git a/test/LinkTest/IncludeHeaders.h b/test/LinkTest/IncludeHeaders.h new file mode 100644 index 000000000..4b73ea3e9 --- /dev/null +++ b/test/LinkTest/IncludeHeaders.h @@ -0,0 +1,53 @@ +#pragma once +/* + * Copyright 2010-2024, Tarantool AUTHORS, please see AUTHORS file. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "src/Buffer/Buffer.hpp" +#include "src/Client/Connection.hpp" +#include "src/Client/Connector.hpp" +#include "src/Client/IprotoConstants.hpp" +#include "src/Client/LibevNetProvider.hpp" +#include "src/Client/RequestEncoder.hpp" +#include "src/Client/ResponseDecoder.hpp" +#include "src/Client/ResponseReader.hpp" +#include "src/Client/Scramble.hpp" +#include "src/Client/Stream.hpp" +#include "src/Client/UnixPlainStream.hpp" +#include "src/Client/UnixStream.hpp" +#include "src/mpp/mpp.hpp" + +#ifdef __linux__ +#include "src/Client/EpollNetProvider.hpp" +#endif + +#ifdef TNTCXX_ENABLE_SSL +#include "src/Client/UnixSSLStream.hpp" +#endif diff --git a/test/LinkTest/Main.cpp b/test/LinkTest/Main.cpp new file mode 100644 index 000000000..ce44e68c5 --- /dev/null +++ b/test/LinkTest/Main.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2024, Tarantool AUTHORS, please see AUTHORS file. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include "IncludeHeaders.h" + +using Buf_t = tnt::Buffer<16 * 1024>; + +#ifdef __linux__ +using NetProvider = EpollNetProvider; +#else +using NetProvider = LibevNetProvider; +#endif + +int +main() +{ + Connector client; + return 0; +} diff --git a/test/LinkTest/Secondary.cpp b/test/LinkTest/Secondary.cpp new file mode 100644 index 000000000..fd417d92c --- /dev/null +++ b/test/LinkTest/Secondary.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2024, Tarantool AUTHORS, please see AUTHORS file. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "IncludeHeaders.h" + +using Buf_t = tnt::Buffer<16 * 1024>; + +#ifdef __linux__ +using NetProvider = EpollNetProvider; +#else +using NetProvider = LibevNetProvider; +#endif + +int foo() +{ + Connector client; + return 0; +}