diff --git a/Makefile b/Makefile index f890f49d2b..4f5b0eb080 100644 --- a/Makefile +++ b/Makefile @@ -2131,6 +2131,11 @@ endif endif #Allow user specify non-default location of boost +# Note: boost::system became fully header-only in Boost 1.78. libboost_system.a +# is no longer generated by modern Boost builds. The OSv kernel only uses +# boost::system for error_code which is entirely in headers; no symbols need +# to be linked. We detect the library if present (for older Boost) but do not +# require it (for Boost 1.78+). ifeq ($(boost_base),) # link with -mt if present, else the base version (and hope it is multithreaded) boost-mt := -mt @@ -2145,7 +2150,8 @@ ifeq ($(boost_base),) boost-includes = ifeq ($(filter /%,$(boost-lib-dir)),) # If the compiler cannot find the boost library, for aarch64 we look in a - # special location before giving up. + # special location. For modern Boost (1.78+) libboost_system.a does not + # exist; we proceed without it since boost::system is header-only. ifeq ($(arch),aarch64) aarch64_boostbase = build/downloaded_packages/aarch64/boost/install ifeq (,$(wildcard $(aarch64_boostbase))) @@ -2155,18 +2161,22 @@ ifeq ($(boost_base),) boost-lib-dir := $(firstword $(dir $(shell find $(aarch64_boostbase)/ -name libboost_system*.a))) boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt) boost-includes = -isystem $(aarch64_boostbase)/usr/include - else - $(error Error: libboost_system.a needs to be installed.) + # else: modern Boost >= 1.78 on x86_64 - libboost_system.a is not needed endif endif else # Use boost specified by the user - boost-lib-dir := $(firstword $(dir $(shell find $(boost_base)/ -name libboost_system*.a))) + boost-lib-dir := $(firstword $(dir $(shell find $(boost_base)/ -name libboost_system*.a 2>/dev/null))) boost-mt := $(if $(filter %-mt.a, $(wildcard $(boost-lib-dir)/*.a)),-mt) - boost-includes = -isystem $(boost_base)/usr/include + # Support both layouts: nixpkgs places headers in $boost_base/include, + # legacy/FHS packages place them in $boost_base/usr/include. + boost-inc-dir := $(firstword $(wildcard $(boost_base)/include) $(wildcard $(boost_base)/usr/include)) + boost-includes = $(if $(boost-inc-dir),-isystem $(boost-inc-dir),) endif -boost-libs := $(boost-lib-dir)/libboost_system$(boost-mt).a +# Only link libboost_system.a if it actually exists (Boost < 1.78). +# Modern Boost (>= 1.78) dropped the compiled library; all functionality is in headers. +boost-libs := $(wildcard $(boost-lib-dir)/libboost_system$(boost-mt).a) objects += fs/nfs/nfs_null_vfsops.o objects += fs/ext/ext_null_vfsops.o diff --git a/conf/base.mk b/conf/base.mk index 15bf20e276..c5c5145a61 100644 --- a/conf/base.mk +++ b/conf/base.mk @@ -8,7 +8,7 @@ conf_logger_debug=0 conf_debug_elf=0 conf_hide_symbols=0 conf_linker_extra_options= -conf_cxx_level=gnu++11 +conf_cxx_level=gnu++14 conf_lazy_stack=0 conf_lazy_stack_invariant=0 diff --git a/core/dhcp.cc b/core/dhcp.cc index ead0a20303..473dfd25c8 100644 --- a/core/dhcp.cc +++ b/core/dhcp.cc @@ -43,7 +43,7 @@ u8 requested_options[] = { dhcp::DHCP_OPTION_HOSTNAME }; -const ip::address_v4 ipv4_zero = ip::address_v4::address_v4::from_string("0.0.0.0"); +const ip::address_v4 ipv4_zero = ip::make_address_v4("0.0.0.0"); // Returns whether we hooked the packet int dhcp_hook_rx(struct mbuf* m) @@ -239,8 +239,8 @@ namespace dhcp { pkt->secs = 0; pkt->flags = 0; memcpy(pkt->chaddr, IF_LLADDR(ifp), ETHER_ADDR_LEN); - ulong yip_n = htonl(yip.to_ulong()); - ulong sip_n = htonl(sip.to_ulong()); + ulong yip_n = htonl(yip.to_uint()); + ulong sip_n = htonl(sip.to_uint()); if(request_packet_type == DHCP_REQUEST_RENEWING || request_packet_type == DHCP_REQUEST_REBINDING) { // ciaddr should only be set to if RENEWING or REBINDING // See pages 21 and 30-31 in https://www.ietf.org/rfc/rfc2131.txt @@ -299,8 +299,8 @@ namespace dhcp { pkt->secs = 0; pkt->flags = 0; memcpy(pkt->chaddr, IF_LLADDR(ifp), ETHER_ADDR_LEN); - ulong yip_n = htonl(yip.to_ulong()); - ulong sip_n = htonl(sip.to_ulong()); + ulong yip_n = htonl(yip.to_uint()); + ulong sip_n = htonl(sip.to_uint()); memcpy(&pkt->ciaddr.s_addr, &yip_n, 4); // Options diff --git a/core/mmu.cc b/core/mmu.cc index 7baa61c0f5..fd48110507 100644 --- a/core/mmu.cc +++ b/core/mmu.cc @@ -26,6 +26,7 @@ #include "dump.hh" #include #include +#include #include #include diff --git a/core/pagecache.cc b/core/pagecache.cc index b146275eee..61f12437a6 100644 --- a/core/pagecache.cc +++ b/core/pagecache.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/loader.cc b/loader.cc index 262cd4c0bd..6c2b406e30 100644 --- a/loader.cc +++ b/loader.cc @@ -647,8 +647,8 @@ void* do_main_thread(void *_main_args) opt_defaultgw.c_str()); } if (opt_nameserver.size() != 0) { - auto addr = boost::asio::ip::address_v4::from_string(opt_nameserver); - osv::set_dns_config({addr}, std::vector()); + auto addr = boost::asio::ip::make_address_v4(opt_nameserver); + osv::set_dns_config({boost::asio::ip::address(addr)}, std::vector()); } #if CONF_networking_dhcp } diff --git a/modules/cloud-init/client.cc b/modules/cloud-init/client.cc index c44f3bdba2..b47652b105 100644 --- a/modules/cloud-init/client.cc +++ b/modules/cloud-init/client.cc @@ -41,7 +41,7 @@ void client::set_header(const std::string& name, const std::string& value) } template -static void connect_with_timeout(boost::asio::io_service& io_service, +static void connect_with_timeout(boost::asio::io_context& io_service, boost::asio::ip::tcp::socket& _socket, tcp::endpoint& _endpoint, boost::system::error_code& ec, Duration duration) { diff --git a/modules/cloud-init/client.hh b/modules/cloud-init/client.hh index 9243363eab..9a758fe57c 100644 --- a/modules/cloud-init/client.hh +++ b/modules/cloud-init/client.hh @@ -86,7 +86,7 @@ private: void process_headers(); boost::asio::streambuf response; unsigned int status_code; - boost::asio::io_service io_service; + boost::asio::io_context io_service; boost::asio::ip::tcp::socket _socket; bool done = false; std::unordered_map _headers; diff --git a/modules/common.gmk b/modules/common.gmk index a229a4a769..47a71acb5f 100644 --- a/modules/common.gmk +++ b/modules/common.gmk @@ -19,7 +19,7 @@ makedir = $(call very-quiet, mkdir -p $(dir $@)) autodepend = -MD -MT $@ -MP ifeq ($(conf_cxx_level),) -conf_cxx_level=gnu++11 +conf_cxx_level=gnu++14 endif # By default, detect HOST_CXX's architecture - x64 or aarch64. @@ -155,9 +155,20 @@ else absolute_boost_base := $(boost_base)# It is absolute already endif # Use boost specified by the user - boost-lib-dir := $(firstword $(dir $(shell find $(absolute_boost_base)/ -name libboost_system.so))) - LDFLAGS += -L$(boost-lib-dir) - boost-includes = -isystem $(absolute_boost_base)/usr/include + # boost::system is header-only since Boost 1.78; libboost_system.so may not exist. + # boost_lib_dir can be set separately (e.g. on NixOS where headers and libs are split). + ifneq ($(boost_lib_dir),) + boost-lib-dir := $(boost_lib_dir) + else + boost-lib-dir := $(firstword $(dir $(shell find $(absolute_boost_base)/ -name libboost_filesystem.so))) + endif + ifneq ($(boost-lib-dir),) + LDFLAGS += -L$(boost-lib-dir) + endif + # Support both layouts: nixpkgs places headers in $boost_base/include, + # legacy/FHS packages place them in $boost_base/usr/include. + boost-inc-dir := $(firstword $(wildcard $(absolute_boost_base)/include) $(wildcard $(absolute_boost_base)/usr/include)) + boost-includes = $(if $(boost-inc-dir),-isystem $(boost-inc-dir),) endif # Let us set INCLUDES given all paths identified above diff --git a/modules/httpserver-api/Makefile b/modules/httpserver-api/Makefile index ccd8551654..73ba4243a4 100644 --- a/modules/httpserver-api/Makefile +++ b/modules/httpserver-api/Makefile @@ -9,7 +9,8 @@ INCLUDES += -I. -I $(src)/libc/internal # -Wall turns on most, but not all, compiler warnings CXXFLAGS = -g -Wall -std=$(conf_cxx_level) -fPIC $(COMMON) -O2 -boost-libs := -lboost_system -lboost_filesystem +# boost::system is header-only since Boost 1.78; link only boost_filesystem +boost-libs := -lboost_filesystem # the build target executable: TARGET = httpserver-api diff --git a/modules/httpserver-api/global_server.cc b/modules/httpserver-api/global_server.cc index 649e62cf39..4c79b72880 100644 --- a/modules/httpserver-api/global_server.cc +++ b/modules/httpserver-api/global_server.cc @@ -221,7 +221,7 @@ void global_server::set_routes() if (!fs::exists(plugin_path) && !fs::is_directory(plugin_path)) return; BOOST_FOREACH(const fs::path& path, std::make_pair(fs::directory_iterator(plugin_path), fs::directory_iterator())) { - if (fs::extension(path)==".so") { + if (path.extension().string()==".so") { load_plugin(path.string()); } } diff --git a/modules/httpserver-api/json/formatter.cc b/modules/httpserver-api/json/formatter.cc index c0691dd4f9..879e8c0380 100644 --- a/modules/httpserver-api/json/formatter.cc +++ b/modules/httpserver-api/json/formatter.cc @@ -8,7 +8,7 @@ #include "formatter.hh" #include "json_elements.hh" #include -#include +#include #include using namespace std; @@ -43,9 +43,9 @@ string formatter::to_json(long n) string formatter::to_json(float f) { int inf; - if ((inf = boost::math::isinf(f))) { + if ((inf = std::isinf(f))) { f = inf * FLT_MAX; - } else if (boost::math::isnan(f)) { + } else if (std::isnan(f)) { f = 0; } return to_string(f); diff --git a/modules/httpserver-api/plain_server.cc b/modules/httpserver-api/plain_server.cc index 0fa56c3c8b..c704579675 100644 --- a/modules/httpserver-api/plain_server.cc +++ b/modules/httpserver-api/plain_server.cc @@ -34,7 +34,7 @@ class plain_transport : public transport callback(ec); } - void async_read_some(boost::asio::mutable_buffers_1 buf, + void async_read_some(boost::asio::mutable_buffer buf, std::function&& callback) override { _socket.async_read_some(buf, std::move(callback)); @@ -52,7 +52,7 @@ class plain_transport : public transport } }; -plain_acceptor::plain_acceptor(boost::asio::io_service& io_service, +plain_acceptor::plain_acceptor(boost::asio::io_context& io_service, tcp::acceptor&& tcp_acceptor) : _io_service(io_service) , _tcp_acceptor(std::move(tcp_acceptor)) diff --git a/modules/httpserver-api/plain_server.hh b/modules/httpserver-api/plain_server.hh index c48a619a6d..9fa719a06a 100644 --- a/modules/httpserver-api/plain_server.hh +++ b/modules/httpserver-api/plain_server.hh @@ -22,11 +22,11 @@ class plain_acceptor : public acceptor public: using socket_t = tcp::socket; private: - boost::asio::io_service& _io_service; + boost::asio::io_context& _io_service; tcp::acceptor _tcp_acceptor; socket_t _socket; public: - plain_acceptor(boost::asio::io_service& io_service, tcp::acceptor&& tcp_acceptor); + plain_acceptor(boost::asio::io_context& io_service, tcp::acceptor&& tcp_acceptor); void do_accept(callback_t on_connected) override; void close() override; }; diff --git a/modules/httpserver-api/server.cc b/modules/httpserver-api/server.cc index b508b9c739..a84474da71 100644 --- a/modules/httpserver-api/server.cc +++ b/modules/httpserver-api/server.cc @@ -43,10 +43,10 @@ server::server(std::map> &config, { // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR). boost::asio::ip::tcp::resolver resolver(io_service_); - boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve({ - options::extract_option_value(config, "ipaddress"), - options::extract_option_value(config, "port") - }); + boost::asio::ip::tcp::endpoint endpoint = + resolver.resolve( + options::extract_option_value(config, "ipaddress"), + options::extract_option_value(config, "port")).begin()->endpoint(); tcp::acceptor tcp_acceptor(io_service_); tcp_acceptor.open(endpoint.protocol()); @@ -112,7 +112,7 @@ void server::on_connected(std::shared_ptr t) void server::close() { - io_service_.dispatch([&] { + boost::asio::dispatch(io_service_, [&] { acceptor_->close(); connection_manager_.stop_all(); io_service_.stop(); diff --git a/modules/httpserver-api/server.hh b/modules/httpserver-api/server.hh index 2da4f57440..8e6457c6c3 100644 --- a/modules/httpserver-api/server.hh +++ b/modules/httpserver-api/server.hh @@ -63,7 +63,7 @@ private: * The io_service used to perform asynchronous operations. * */ - boost::asio::io_service io_service_; + boost::asio::io_context io_service_; /** * Acceptor used to listen for incoming connections. diff --git a/modules/httpserver-api/ssl_server.cc b/modules/httpserver-api/ssl_server.cc index e732624e66..737b063346 100644 --- a/modules/httpserver-api/ssl_server.cc +++ b/modules/httpserver-api/ssl_server.cc @@ -38,7 +38,7 @@ class ssl_transport : public transport { }); } - void async_read_some(boost::asio::mutable_buffers_1 buf, + void async_read_some(boost::asio::mutable_buffer buf, std::function&& callback) override { _socket->async_read_some(buf, std::move(callback)); @@ -56,7 +56,7 @@ class ssl_transport : public transport { } }; -ssl_acceptor::ssl_acceptor(boost::asio::io_service& io_service, +ssl_acceptor::ssl_acceptor(boost::asio::io_context& io_service, boost::asio::ssl::context&& ctx, tcp::acceptor&& tcp_acceptor) : _io_service(io_service) diff --git a/modules/httpserver-api/ssl_server.hh b/modules/httpserver-api/ssl_server.hh index a2c0935d65..a8fab00da1 100644 --- a/modules/httpserver-api/ssl_server.hh +++ b/modules/httpserver-api/ssl_server.hh @@ -22,11 +22,11 @@ namespace ssl = boost::asio::ssl; class ssl_acceptor : public acceptor { private: - boost::asio::io_service& _io_service; + boost::asio::io_context& _io_service; ssl::context _ctx; tcp::acceptor _tcp_acceptor; public: - ssl_acceptor(boost::asio::io_service& io_service, + ssl_acceptor(boost::asio::io_context& io_service, boost::asio::ssl::context&& ctx, tcp::acceptor&& tcp_acceptor); diff --git a/modules/httpserver-api/transport.hh b/modules/httpserver-api/transport.hh index d06a8df72e..8e4cef4e08 100644 --- a/modules/httpserver-api/transport.hh +++ b/modules/httpserver-api/transport.hh @@ -21,7 +21,7 @@ class transport { public: virtual void close(std::function callback) = 0; - virtual void async_read_some(boost::asio::mutable_buffers_1 buf, + virtual void async_read_some(boost::asio::mutable_buffer buf, std::function&& callback) = 0; virtual void async_write(std::vector buffers, diff --git a/modules/libz/Makefile b/modules/libz/Makefile index b0e6b24978..dcf0977fa8 100644 --- a/modules/libz/Makefile +++ b/modules/libz/Makefile @@ -1,5 +1,11 @@ # Take libz.so from the build machine and put it in the image. very-quiet = $(if $V, $1, @$1) -libz = $(shell $(CC) -print-file-name=libz.so.1) +libz_cc = $(shell $(CC) -print-file-name=libz.so.1) +# On NixOS, CC -print-file-name returns a relative path; fall back to LD_LIBRARY_PATH search. +libz = $(if $(filter /%,$(libz_cc)),$(libz_cc),$(firstword $(shell \ + for d in $$(echo "$$LD_LIBRARY_PATH" | tr ':' ' '); do \ + f=$$(find "$$d" -maxdepth 1 -name 'libz.so.1' 2>/dev/null | head -1); \ + test -n "$$f" && echo "$$f" && break; \ + done))) module: $(call very-quiet, echo /usr/lib/libz.so.1: $(libz) > usr.manifest) diff --git a/modules/monitoring-agent/client.cc b/modules/monitoring-agent/client.cc index abff651017..3cd5cda05b 100644 --- a/modules/monitoring-agent/client.cc +++ b/modules/monitoring-agent/client.cc @@ -36,7 +36,7 @@ client::client(int _time_out) { } template -static void connect_with_timeout(boost::asio::io_service& io_service, +static void connect_with_timeout(boost::asio::io_context& io_service, boost::asio::ip::tcp::socket& _socket, tcp::endpoint& _endpoint, boost::system::error_code& ec, Duration duration) { diff --git a/modules/monitoring-agent/client.hh b/modules/monitoring-agent/client.hh index dccbe2dc4f..3e83d2eb31 100644 --- a/modules/monitoring-agent/client.hh +++ b/modules/monitoring-agent/client.hh @@ -86,7 +86,7 @@ private: void process_headers(); boost::asio::streambuf response; unsigned int status_code; - boost::asio::io_service io_service; + boost::asio::io_context io_service; boost::asio::ip::tcp::socket _socket; bool done = false; int time_out; diff --git a/modules/openssl/Makefile b/modules/openssl/Makefile index b7727a37a2..20f04046a2 100644 --- a/modules/openssl/Makefile +++ b/modules/openssl/Makefile @@ -7,13 +7,18 @@ SRC = $(shell readlink -f ../..) module: - $(SRC)/scripts/manifest_from_host.sh -l libssl.so.1.1 > usr.manifest - # From krb5-libs - $(SRC)/scripts/manifest_from_host.sh -l libgssapi_krb5.so.2 >> usr.manifest - # From libselinux - $(SRC)/scripts/manifest_from_host.sh -l libselinux.so.1 >> usr.manifest - # From xz-libs - $(SRC)/scripts/manifest_from_host.sh -l liblzma.so.5 >> usr.manifest + # Support OpenSSL 3.x (libssl.so.3) and legacy 1.1.x (libssl.so.1.1). + # OpenSSL 3.x is the current standard on modern distros and NixOS. + if $(SRC)/scripts/manifest_from_host.sh -l libssl.so.3 > usr.manifest 2>/dev/null && \ + grep -q libssl usr.manifest 2>/dev/null; then \ + true; \ + else \ + $(SRC)/scripts/manifest_from_host.sh -l libssl.so.1.1 > usr.manifest; \ + fi + # Optional runtime dependencies -- silently ignored if absent on host + $(SRC)/scripts/manifest_from_host.sh -li libgssapi_krb5.so.2 >> usr.manifest + $(SRC)/scripts/manifest_from_host.sh -li libselinux.so.1 >> usr.manifest + $(SRC)/scripts/manifest_from_host.sh -li liblzma.so.5 >> usr.manifest .PHONY: module diff --git a/scripts/manifest_from_host.sh b/scripts/manifest_from_host.sh index d16b8a3498..ff10b3ff06 100755 --- a/scripts/manifest_from_host.sh +++ b/scripts/manifest_from_host.sh @@ -45,6 +45,22 @@ find_library() local pattern="$1" local count=$(ldconfig -p | grep -P "$pattern" | grep "${MACHINE}" | wc -l) + # On NixOS / Nix dev-shell, ldconfig -p returns nothing because libraries + # live in /nix/store and are not registered in the system ldconfig cache. + # Fall back to searching directories listed in LD_LIBRARY_PATH. + if [[ $count == 0 ]] && [[ -n "$LD_LIBRARY_PATH" ]]; then + local IFS=':' + for dir in $LD_LIBRARY_PATH; do + local found=$(find "$dir" -maxdepth 1 -name "*.so*" 2>/dev/null \ + | grep -P "$pattern" | sort -V | tail -1) + if [[ -n "$found" ]]; then + so_name=$(basename "$found") + so_path="$found" + return 0 + fi + done + fi + if [[ $count == 0 && $IGNORE_MISSING == false ]]; then echo "Could not find any so file matching $pattern" >&2 return -1 @@ -66,6 +82,10 @@ output_manifest() { local so_files="$1" local so_filter="$2" + if [ -z "$LDDTREE_INSTALLED" ]; then + echo "Please install lddtree which is part of pax-utils package" >&2 + exit 1 + fi echo "# --------------------" | tee -a $OUTPUT echo "# Dependencies " | tee -a $OUTPUT echo "# --------------------" | tee -a $OUTPUT @@ -74,13 +94,13 @@ output_manifest() sed 's/.*=> //' | awk '// { printf("%s: %s\n", $0, $0); }' | sort | uniq | tee -a $OUTPUT echo "/etc/ld.so.cache: /etc/ld.so.cache" | tee -a $OUTPUT elif [[ $conf_hide_symbols == 1 ]]; then - lddtree $so_files | grep -v "not found" | grep -v "$so_filter" | grep -v "ld-linux-${MACHINE}" | \ + lddtree $so_files | grep -v "not found" | grep -v " => None" | grep -v "$so_filter" | grep -v "ld-linux-${MACHINE}" | \ grep -Pv 'lib(gcc_s|resolv|c|m|pthread|dl|rt|aio|xenstore|crypt|selinux)\.so([\d.]+)?' | \ - sed 's/ =>/:/' | sed 's/^\s*lib/\/usr\/lib\/lib/' | sort | uniq | tee -a $OUTPUT + sed 's/ =>/:/' | sed 's/^\s*lib/\/usr\/lib\/lib/' | grep -v ': None$' | sort | uniq | tee -a $OUTPUT else - lddtree $so_files | grep -v "not found" | grep -v "$so_filter" | grep -v "ld-linux-${MACHINE}" | \ + lddtree $so_files | grep -v "not found" | grep -v " => None" | grep -v "$so_filter" | grep -v "ld-linux-${MACHINE}" | \ grep -Pv 'lib(gcc_s|resolv|c|m|pthread|dl|rt|stdc\+\+|aio|xenstore|crypt|selinux)\.so([\d.]+)?' | \ - sed 's/ =>/:/' | sed 's/^\s*lib/\/usr\/lib\/lib/' | sort | uniq | tee -a $OUTPUT + sed 's/ =>/:/' | sed 's/^\s*lib/\/usr\/lib\/lib/' | grep -v ': None$' | sort | uniq | tee -a $OUTPUT fi } @@ -135,10 +155,6 @@ shift $((OPTIND - 1)) [[ -z $1 ]] && usage 1 LDDTREE_INSTALLED=$(command -v lddtree) -if [ -z "$LDDTREE_INSTALLED" ]; then - echo "Please install lddtree which is part of pax-utils package" >&2 - exit 1 -fi NAME_OR_PATH="$1" SUBDIRECTORY_PATH="$2" diff --git a/tests/misc-tcp.cc b/tests/misc-tcp.cc index ec98fc8693..ca6b8be2da 100644 --- a/tests/misc-tcp.cc +++ b/tests/misc-tcp.cc @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ class tcp_test_client { private: tcp_test_client& _client; unique_lock _lock; - boost::asio::io_service _io; + boost::asio::io_context _io; thread _thread; }; friend class test_thread; @@ -98,12 +98,13 @@ void tcp_test_client::test_thread::do_connection(int c) unique_lock lock_dropper(rev_lock); boost::asio::ip::tcp::socket socket(_io); boost::asio::ip::tcp::resolver resolver(_io); - boost::asio::ip::tcp::resolver::query query(_client._p.remote, "9999"); - auto i = resolver.resolve(query); - if (i == decltype(resolver)::iterator()) { + /* Boost.Asio >= 1.74 removed resolver::query; resolve(host, port) + * returns a results_type range directly. */ + auto results = resolver.resolve(_client._p.remote, "9999"); + if (results.empty()) { throw runtime_error("cannot resolve address"); } - auto endpoint = *i; + auto endpoint = results.begin()->endpoint(); socket.open(boost::asio::ip::tcp::v4()); // for set_option() socket.set_option(decltype(socket)::reuse_address(true)); socket.connect(endpoint); @@ -117,7 +118,7 @@ void tcp_test_client::test_thread::do_connection(int c) auto offset_buffer = offset; while (done < transfer && offset < b_size) { auto tmp = boost::asio::buffer(send_buffer, transfer - offset_buffer) + offset; - auto delta = socket.write_some(boost::asio::const_buffers_1(tmp)); + auto delta = socket.write_some(boost::asio::const_buffer(tmp)); if (!delta) { throw runtime_error("short write"); } @@ -127,7 +128,7 @@ void tcp_test_client::test_thread::do_connection(int c) offset = 0; while (rdone < transfer && offset < b_size) { auto tmp = boost::asio::buffer(receive_buffer, transfer - offset_buffer) + offset; - auto delta = socket.read_some(boost::asio::mutable_buffers_1(tmp)); + auto delta = socket.read_some(boost::asio::mutable_buffer(tmp)); if (!delta) { throw runtime_error("short read"); } diff --git a/tests/tst-bsd-tcp1-zrcv.cc b/tests/tst-bsd-tcp1-zrcv.cc index 9cb33f1068..e02fc2059a 100644 --- a/tests/tst-bsd-tcp1-zrcv.cc +++ b/tests/tst-bsd-tcp1-zrcv.cc @@ -264,10 +264,10 @@ BOOST_AUTO_TEST_CASE(test_tcp_client_server) BOOST_AUTO_TEST_CASE(test_shutdown_wr) { using namespace boost::asio::ip; - boost::asio::io_service io_service; + boost::asio::io_context io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 10000)); tcp::socket client(io_service); - client.connect(tcp::endpoint(address_v4::from_string("127.0.0.1"), 10000)); + client.connect(tcp::endpoint(make_address_v4("127.0.0.1"), 10000)); tcp::socket server(io_service); acceptor.accept(server); server.shutdown(tcp::socket::shutdown_send); diff --git a/tests/tst-bsd-tcp1-zsnd.cc b/tests/tst-bsd-tcp1-zsnd.cc index 032ef6d869..8650cd16e7 100644 --- a/tests/tst-bsd-tcp1-zsnd.cc +++ b/tests/tst-bsd-tcp1-zsnd.cc @@ -266,10 +266,10 @@ BOOST_AUTO_TEST_CASE(test_tcp_client_server) BOOST_AUTO_TEST_CASE(test_shutdown_wr) { using namespace boost::asio::ip; - boost::asio::io_service io_service; + boost::asio::io_context io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 10000)); tcp::socket client(io_service); - client.connect(tcp::endpoint(address_v4::from_string("127.0.0.1"), 10000)); + client.connect(tcp::endpoint(make_address_v4("127.0.0.1"), 10000)); tcp::socket server(io_service); acceptor.accept(server); server.shutdown(tcp::socket::shutdown_send); diff --git a/tests/tst-bsd-tcp1-zsndrcv.cc b/tests/tst-bsd-tcp1-zsndrcv.cc index 2e908415a9..8f9c01c30e 100644 --- a/tests/tst-bsd-tcp1-zsndrcv.cc +++ b/tests/tst-bsd-tcp1-zsndrcv.cc @@ -291,10 +291,10 @@ BOOST_AUTO_TEST_CASE(test_tcp_client_server) BOOST_AUTO_TEST_CASE(test_shutdown_wr) { using namespace boost::asio::ip; - boost::asio::io_service io_service; + boost::asio::io_context io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 10000)); tcp::socket client(io_service); - client.connect(tcp::endpoint(address_v4::from_string("127.0.0.1"), 10000)); + client.connect(tcp::endpoint(make_address_v4("127.0.0.1"), 10000)); tcp::socket server(io_service); acceptor.accept(server); server.shutdown(tcp::socket::shutdown_send); diff --git a/tests/tst-bsd-tcp1.cc b/tests/tst-bsd-tcp1.cc index 744255b54b..b55494a409 100644 --- a/tests/tst-bsd-tcp1.cc +++ b/tests/tst-bsd-tcp1.cc @@ -223,10 +223,10 @@ BOOST_AUTO_TEST_CASE(test_tcp_client_server) BOOST_AUTO_TEST_CASE(test_shutdown_wr) { using namespace boost::asio::ip; - boost::asio::io_service io_service; + boost::asio::io_context io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 10000)); tcp::socket client(io_service); - client.connect(tcp::endpoint(address_v4::from_string("127.0.0.1"), 10000)); + client.connect(tcp::endpoint(make_address_v4("127.0.0.1"), 10000)); tcp::socket server(io_service); acceptor.accept(server); server.shutdown(tcp::socket::shutdown_send); diff --git a/tools/cpiod/cpiod.cc b/tools/cpiod/cpiod.cc index 24e1f93188..7c5e2f301e 100644 --- a/tools/cpiod/cpiod.cc +++ b/tools/cpiod/cpiod.cc @@ -177,12 +177,13 @@ int main(int ac, char** av) return 1; } - boost::asio::io_service io_service; + boost::asio::io_context io_service; tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), port)); - cout << "Waiting for connection from host...\n"; - boost::asio::ip::tcp::iostream socket; - acceptor.accept(*socket.rdbuf()); + cout << "Waiting for connection from host..." << endl; + boost::asio::ip::tcp::socket raw_socket(io_service); + acceptor.accept(raw_socket); + boost::asio::ip::tcp::iostream socket(std::move(raw_socket)); cpio_in_expand expand_files(prefix, verbose); cpio_in::parse(socket, expand_files); sync();