Linux + iPhone Continuity / iMessage / SMS
Backedout AI-based scope creep
sfreeman422d22f1f444334
diff --git a/src/core/include/tether/event_loop.hpp b/src/core/include/tether/event_loop.hppindex 720162c..6f8d164 100644--- a/src/core/include/tether/event_loop.hpp+++ b/src/core/include/tether/event_loop.hpp@@ -42,7 +42,6 @@ namespace tether {int post_fd_ = -1;std::atomic<bool> running_;std::map<int, Callback> callbacks_;- std::mutex callbacks_mutex_;std::mutex post_mutex_;std::vector<std::function<void()>> posted_;};diff --git a/src/core/src/event_loop.cpp b/src/core/src/event_loop.cppindex 7498b8c..6e1d543 100644--- a/src/core/src/event_loop.cpp+++ b/src/core/src/event_loop.cpp@@ -69,7 +69,6 @@ namespace tether {debug::log(ERR, "Failed to add fd to epoll: {}", fd);return false;}- std::lock_guard<std::mutex> lock(callbacks_mutex_);callbacks_[fd] = std::move(cb);return true;}@@ -78,7 +77,6 @@ namespace tether {if (epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, nullptr) < 0) {return false;}- std::lock_guard<std::mutex> lock(callbacks_mutex_);callbacks_.erase(fd);return true;}@@ -99,28 +97,16 @@ namespace tether {for (int i = 0; i < n; ++i) {int fd = events[i].data.fd;- Callback cb;- {- std::lock_guard<std::mutex> lock(callbacks_mutex_);- auto it = callbacks_.find(fd);- if (it == callbacks_.end())- continue;- cb = it->second;+ auto it = callbacks_.find(fd);+ if (it != callbacks_.end()) {+ it->second(fd);}- // Copy the callback to ensure it stays alive even if removeFd is called inside it.- cb(fd);}}}void EpollEventLoop::stop() {running_ = false;- if (post_fd_ >= 0) {- uint64_t one = 1;- if (write(post_fd_, &one, sizeof(one)) < 0 && errno != EAGAIN && errno != EWOULDBLOCK) {- debug::log(ERR, "Failed to wake the event loop during stop");- }- }}} // namespace tetherdiff --git a/test/test_event_loop.cpp b/test/test_event_loop.cppindex 7ec3683..b4d60ee 100644--- a/test/test_event_loop.cpp+++ b/test/test_event_loop.cpp@@ -2,8 +2,6 @@#include <tether/event_loop.hpp>#include <atomic>-#include <chrono>-#include <future>#include <thread>using namespace tether;@@ -41,13 +39,3 @@ TEST(EventLoopTest, RunsWorkPostedBeforeRun) {EXPECT_TRUE(ran);}--TEST(EventLoopTest, StopFromAnotherThreadWakesTheLoop) {- EpollEventLoop loop;- auto run_future = std::async(std::launch::async, [&] { loop.run(); });-- std::this_thread::sleep_for(std::chrono::milliseconds(50));- loop.stop();-- EXPECT_EQ(run_future.wait_for(std::chrono::seconds(2)), std::future_status::ready);-}diff --git a/test/test_net.cpp b/test/test_net.cppindex ac3f9a0..cfa042c 100644--- a/test/test_net.cpp+++ b/test/test_net.cpp@@ -147,19 +147,6 @@ namespace {std::streambuf* previous_ = nullptr;};- // Helper RAII class to manage event loop lifecycle- class EventLoopGuard {- public:- EventLoopGuard(tether::EpollEventLoop* loop) : loop_(loop) {}- ~EventLoopGuard() {- if (loop_)- loop_->stop();- }-- private:- tether::EpollEventLoop* loop_;- };-TEST(TcpServerTest, ReportsWhyATlsHandshakeFailed) {const std::string home = "/tmp/tether_net_test";CleanupGuard cleanup_guard(home);@@ -175,7 +162,6 @@ namespace {GTEST_SKIP() << "port " << port << " is unavailable";CerrCapture captured;- EventLoopGuard loop_guard(&loop);std::thread loop_thread([&loop] { loop.run(); });const int client = socket(AF_INET, SOCK_STREAM, 0);@@ -199,7 +185,7 @@ namespace {std::this_thread::sleep_for(std::chrono::milliseconds(10));}- loop.stop();+ loop.post([&loop] { loop.stop(); });loop_thread.join();captured.restore();