Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ projects/intel_x86/linux/gcc/aether-client-cpp
*.vs

.updated

# Local Android / desktop probe builds
/build-android*/
/build-windows*/
*.log

23 changes: 21 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ project(aether VERSION ${AE_PROJECT_VERSION} LANGUAGES CXX C)

set(TARGET_NAME "${PROJECT_NAME}")

# Android shared-library consumers require PIC for static archives.
if(ANDROID)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

if("${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
set(AE_ROOT_PORJECT On)
else()
Expand All @@ -56,6 +61,7 @@ option(AE_INSTALL "Install aether" ${AE_ROOT_PORJECT})
option(AE_BUILD_TOOLS "Build tools" ${AE_ROOT_PORJECT})
option(AE_BUILD_EXAMPLES "Build examples" ${AE_ROOT_PORJECT})
option(AE_BUILD_TESTS "Build tests" ${AE_ROOT_PORJECT})
option(AE_BUILD_ANDROID_SMOKE "Build Android NDK smoke shared library and runner" Off)
option(AE_ADDRESS_SANITIZE "Enable address sanitizer" Off)
option(AE_NO_STRIP_ALL "Do not apply --strip_all, useful for bloaty and similar tools " Off)

Expand All @@ -72,6 +78,7 @@ message(STATUS "Aether build options:
AE_BUILD_TOOLS=${AE_BUILD_TOOLS}
AE_BUILD_EXAMPLES=${AE_BUILD_EXAMPLES}
AE_BUILD_TESTS=${AE_BUILD_TESTS}
AE_BUILD_ANDROID_SMOKE=${AE_BUILD_ANDROID_SMOKE}
AE_ADDRESS_SANITIZE=${AE_ADDRESS_SANITIZE}
AE_NO_STRIP_ALL=${AE_NO_STRIP_ALL}
UTM_ID=${UTM_ID}
Expand Down Expand Up @@ -188,8 +195,9 @@ message(STATUS "Aether build for CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux"
OR CMAKE_SYSTEM_NAME STREQUAL "Darwin"
OR CMAKE_SYSTEM_NAME MATCHES ".*BSD.*"
OR CMAKE_SYSTEM_NAME STREQUAL "Windows" )
# for desktop projects add c-ares
OR CMAKE_SYSTEM_NAME STREQUAL "Windows"
OR CMAKE_SYSTEM_NAME STREQUAL "Android" )
# for desktop and Android projects add c-ares
CPMAddPackage(
NAME c-ares
GIT_REPOSITORY "https://github.com/c-ares/c-ares.git"
Expand Down Expand Up @@ -388,6 +396,17 @@ if(AE_BUILD_TESTS)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tests ${CMAKE_BINARY_DIR}/tests)
endif()

if(ANDROID AND AE_BUILD_ANDROID_SMOKE)
message(STATUS "Aether builds Android NDK smoke targets!")
# Shared-library consumers require PIC for aether and static dependencies.
set_property(TARGET ${TARGET_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
if(TARGET c-ares)
set_property(TARGET c-ares PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tests/android_ndk_smoke
${CMAKE_BINARY_DIR}/android_ndk_smoke)
endif()

if(AE_INSTALL)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
Expand Down
2 changes: 1 addition & 1 deletion aether/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ list(APPEND aether_srcs

list(APPEND aether_srcs
"server_connections/client_server_connection.cpp"
"server_connections/channel_connection.cpp"
"server_connections/channel_select_action.cpp"
"server_connections/server_connection.cpp")

list(APPEND aether_srcs
Expand Down
8 changes: 5 additions & 3 deletions aether/channels/ethernet_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ namespace ethernet_access_point_internal {
using ResolveSender =
ex::AnySender<ex::set_value_t(std::vector<Endpoint>), ex::set_error_t(int)>;

ResolveSender ResolveAddress(Ptr<DnsResolver> const& resolver,
NamedAddr const& addr, std::uint16_t port,
Protocol protocol) {
ResolveSender ResolveAddress(
[[maybe_unused]] Ptr<DnsResolver> const& resolver,
[[maybe_unused]] NamedAddr const& addr,
[[maybe_unused]] std::uint16_t port,
[[maybe_unused]] Protocol protocol) {
#if AE_SUPPORT_CLOUD_DNS
return resolver->Resolve(addr, port, protocol);
#else
Expand Down
43 changes: 33 additions & 10 deletions aether/cloud_connections/cloud_server_connections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "aether/server.h"
#include "aether/server_connections/server_connection.h"

#include "aether/cloud_connections/cloud_connections_tele.h"
#include "aether/cloud_connections/cloud_connections_tele.h" // IWYU pragma: keep

namespace ae {

Expand Down Expand Up @@ -149,15 +149,23 @@ void CloudServerConnections::SubscribeToServerState(
if (conn == nullptr) {
return;
}

if (conn->stream_info().link_state == LinkState::kLinked) {
AE_TELED_DEBUG("CLOUD_SERVER_LINKED server_id={} priority={}",
server_connection.server()->server_id,
server_connection.priority());
}

auto const key = reinterpret_cast<std::uintptr_t>(&server_connection);
auto& subs = server_subs_[key] = {};
subs.state_sub = conn->stream_update_event().Subscribe(
[this, sc{&server_connection}, conn]() {
if (conn->stream_info().link_state == LinkState::kLinkError) {
QuarantineServer(*sc);
return true;
} else if (conn->stream_info().link_state == LinkState::kLinked) {
AE_TELED_DEBUG("CLOUD_SERVER_LINKED server_id={} priority={}",
sc->server()->server_id, sc->priority());
}
return false;
});
subs.error_sub = conn->server_connection().server_error_event().Subscribe(
[this, sc{&server_connection}]() { QuarantineServer(*sc); });
Expand All @@ -182,7 +190,7 @@ void CloudServerConnections::QuarantineServer(
if (server_connection.quarantine()) {
return;
}
AE_TELED_DEBUG("Quarantine server server_id={} priority={}",
AE_TELED_DEBUG("CLOUD_SERVER_QUARANTINED server_id={} priority={}",
server_connection.server()->server_id,
server_connection.priority());
UnsubscribeFromServerState(server_connection);
Expand All @@ -193,14 +201,21 @@ void CloudServerConnections::QuarantineServer(
server_connection.SetPriority(server_connections_.size());
server_connection.SetQuarantine(true);
server_quarantined_event_.Emit(&server_connection);
server_subs_[key].quarantine_sub = ae_context_.scheduler().DelayedTask(

// One delayed release: Disconnect + clear quarantine + reconcile. Do not
// Disconnect on the error-callback stack.
auto& quarantine_sub = server_subs_[key].quarantine_sub;
quarantine_sub = ae_context_.scheduler().DelayedTask(
[this, sc{&server_connection}, key]() {
ReleaseQuarantinedServer(*sc, key);
},
kCloudServerQuarantineTime);
if (!server_subs_[key].quarantine_sub) {
assert(false && "Failed to schedule quarantine release task");

if (!quarantine_sub) {
AE_TELED_ERROR("CLOUD_QUARANTINE_RELEASE_ALLOC_FAILED");
assert(false && "failed to schedule quarantine release");
}

ScheduleReconcileServers();
}

Expand All @@ -209,7 +224,7 @@ void CloudServerConnections::ReleaseQuarantinedServer(
if (!server_connection.quarantine()) {
return;
}
AE_TELED_DEBUG("Release quarantined server server_id={} priority={}",
AE_TELED_DEBUG("CLOUD_SERVER_RELEASED server_id={} priority={}",
server_connection.server()->server_id,
server_connection.priority());
server_quarantine_release_event_.Emit(&server_connection);
Expand All @@ -222,6 +237,7 @@ void CloudServerConnections::ReleaseQuarantinedServer(
server_subs_.erase(it);
}
}

ScheduleReconcileServers();
}

Expand All @@ -233,6 +249,11 @@ void CloudServerConnections::ScheduleReconcileServers() {
defer_sub_.Reset();
ReconcileServers();
});
if (!defer_sub_) {
AE_TELED_ERROR(
"CLOUD_SCHEDULE_RECONCILE_ALLOC_FAILED; pending until release");
assert(false && "failed to schedule reconcile servers");
}
}

void CloudServerConnections::ReconcileServers() {
Expand All @@ -252,6 +273,8 @@ void CloudServerConnections::ReconcileServers() {
break;
}
candidate->SetPriority(selected_servers_.size());
AE_TELED_DEBUG("CLOUD_SERVER_RECONNECT_ATTEMPT server_id={} priority={}",
candidate->server()->server_id, candidate->priority());
candidate->Connect();
auto* conn = candidate->client_connection();
if (conn == nullptr ||
Expand Down Expand Up @@ -284,8 +307,8 @@ void CloudServerConnections::UpdateSelectedPriorities() {
}
}

std::vector<CloudServerConnection*>
CloudServerConnections::ReplacementCandidates() {
auto CloudServerConnections::ReplacementCandidates()
-> std::vector<CloudServerConnection*> {
std::vector<CloudServerConnection*> servers;
servers.reserve(server_connections_.size());
for (auto& s : server_connections_) {
Expand Down
78 changes: 0 additions & 78 deletions aether/server_connections/channel_connection.cpp

This file was deleted.

57 changes: 0 additions & 57 deletions aether/server_connections/channel_connection.h

This file was deleted.

Loading
Loading