From 2756b9b990b5d41b8513a6e5a0854856cc5052f0 Mon Sep 17 00:00:00 2001 From: Travis Downs Date: Fri, 20 Sep 2024 11:40:08 -0300 Subject: [PATCH 1/2] thread_pool: fix includes No system headers included if SEASTAR_MODULES was undefined, fix it to the usual pattern. --- src/core/thread_pool.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/thread_pool.cc b/src/core/thread_pool.cc index c88f0f53db..3dcc9502b2 100644 --- a/src/core/thread_pool.cc +++ b/src/core/thread_pool.cc @@ -22,12 +22,16 @@ #ifdef SEASTAR_MODULE module; +#endif + #include #include #include #include #include #include + +#ifdef SEASTAR_MODULE module seastar; #else #include From 188baf14a42e176c71ac843ed645c80a8bd33505 Mon Sep 17 00:00:00 2001 From: Travis Downs Date: Fri, 20 Sep 2024 12:07:24 -0300 Subject: [PATCH 2/2] warnings: fix unused result warnings Fix a few unused result warnings that have popped up in gcc. In some cases this involves actually checking the return type, mostly for write(event_fd,...) and in this case it seems that we never expect any type of failure here (non-zero return code would only be on eventfd wrap if fd is in blocking mode, invalid arguments). --- src/core/reactor.cc | 8 +++++--- src/core/thread_pool.cc | 3 ++- tests/perf/linux_perf_event.cc | 5 ++++- tests/unit/unix_domain_test.cc | 17 +++++++++++------ 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/core/reactor.cc b/src/core/reactor.cc index 1ddda9e6ed..2b6199ac33 100644 --- a/src/core/reactor.cc +++ b/src/core/reactor.cc @@ -2906,7 +2906,8 @@ reactor::wakeup() { _sleeping.store(false, std::memory_order_relaxed); uint64_t one = 1; - ::write(_notify_eventfd.get(), &one, sizeof(one)); + auto res = ::write(_notify_eventfd.get(), &one, sizeof(one)); + assert(res == sizeof(one) && "write(2) failed on _reactor._notify_eventfd"); } void reactor::start_aio_eventfd_loop() { @@ -2916,7 +2917,7 @@ void reactor::start_aio_eventfd_loop() { future<> loop_done = repeat([this] { return _aio_eventfd->readable().then([this] { char garbage[8]; - ::read(_aio_eventfd->get_fd(), garbage, 8); // totally uninteresting + std::ignore = ::read(_aio_eventfd->get_fd(), garbage, 8); // totally uninteresting return _stopping ? stop_iteration::yes : stop_iteration::no; }); }); @@ -2931,7 +2932,8 @@ void reactor::stop_aio_eventfd_loop() { return; } uint64_t one = 1; - ::write(_aio_eventfd->get_fd(), &one, 8); + auto res = ::write(_aio_eventfd->get_fd(), &one, 8); + assert(res == 8 && "write(2) failed on _reactor._aio_eventfd"); } inline diff --git a/src/core/thread_pool.cc b/src/core/thread_pool.cc index 3dcc9502b2..2b697bcdf2 100644 --- a/src/core/thread_pool.cc +++ b/src/core/thread_pool.cc @@ -70,7 +70,8 @@ void thread_pool::work(sstring name) { std::atomic_thread_fence(std::memory_order_seq_cst); if (_main_thread_idle.load(std::memory_order_relaxed)) { uint64_t one = 1; - ::write(_reactor._notify_eventfd.get(), &one, 8); + auto res = ::write(_reactor._notify_eventfd.get(), &one, 8); + assert(res == 8 && "write(2) failed on _reactor._notify_eventfd"); } } } diff --git a/tests/perf/linux_perf_event.cc b/tests/perf/linux_perf_event.cc index 16c06bb6a4..f36a94e9f9 100644 --- a/tests/perf/linux_perf_event.cc +++ b/tests/perf/linux_perf_event.cc @@ -24,6 +24,8 @@ * This file was copied from Scylla (https://github.com/scylladb/scylla) */ +#include + #include #include @@ -61,7 +63,8 @@ linux_perf_event::read() { return 0; } uint64_t ret; - ::read(_fd, &ret, sizeof(ret)); + auto res = ::read(_fd, &ret, sizeof(ret)); + assert(res == sizeof(ret) && "read(2) failed on perf_event fd"); return ret; } diff --git a/tests/unit/unix_domain_test.cc b/tests/unit/unix_domain_test.cc index c3211ab72c..54ebbc8165 100644 --- a/tests/unit/unix_domain_test.cc +++ b/tests/unit/unix_domain_test.cc @@ -17,7 +17,7 @@ */ /* * Copyright (C) 2019 Red Hat, Inc. - */ + */ #include @@ -88,7 +88,7 @@ future<> ud_server_client::init_server() { } } client_round(); - } + } }); return do_until([this](){return rounds_left<=0;}, [&lstn,this]() { @@ -131,7 +131,7 @@ future<> ud_server_client::init_server() { /// If 'client_path' is set, the client binds to the named path. // Runs in a seastar::thread. void ud_server_client::client_round() { - auto cc = client_path ? + auto cc = client_path ? engine().net().connect(server_addr, socket_address{unix_domain_addr{*client_path}}).get() : engine().net().connect(server_addr).get(); @@ -154,11 +154,16 @@ future<> ud_server_client::run() { } +void rm(std::string_view what) { + auto res = system(fmt::format("rm -f {}", what).c_str()); + BOOST_REQUIRE_EQUAL(res, 0); +} + // testing the various address types, both on the server and on the // client side SEASTAR_TEST_CASE(unixdomain_server) { - system("rm -f /tmp/ry"); + rm("/tmp/ry"); ud_server_client uds("/tmp/ry", std::nullopt, 3); return do_with(std::move(uds), [](auto& uds){ return uds.run(); @@ -205,7 +210,7 @@ SEASTAR_TEST_CASE(unixdomain_text) { } SEASTAR_TEST_CASE(unixdomain_bind) { - system("rm -f 111 112"); + rm("111 112"); ud_server_client uds("111"s, "112"s, 1); return do_with(std::move(uds), [](auto& uds){ return uds.run(); @@ -213,7 +218,7 @@ SEASTAR_TEST_CASE(unixdomain_bind) { } SEASTAR_TEST_CASE(unixdomain_short) { - system("rm -f 3"); + rm("3"); ud_server_client uds("3"s, std::nullopt, 10); return do_with(std::move(uds), [](auto& uds){ return uds.run();