Skip to content

Commit 84acd2e

Browse files
committed
fixed logging
1 parent 5ddd54b commit 84acd2e

File tree

8 files changed

+39
-26
lines changed

8 files changed

+39
-26
lines changed

generator/src/synchronous_generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ namespace synchronous_generator
10241024
stub("}}");
10251025
}
10261026

1027-
stub("#ifdef USE_RPC_LOGGING");
1027+
stub("#ifdef CANOPY_USE_LOGGING");
10281028
stub("catch(const std::exception& ex)");
10291029
stub("{{");
10301030
stub("RPC_ERROR(\"Exception has occurred in an {} implementation in function {} {{}}\", ex.what());",

generator/src/yas_generator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ namespace yas_generator
590590
proxy("return rpc::error::PROXY_DESERIALISATION_ERROR();");
591591
proxy("}}");
592592
proxy("}}");
593-
proxy("#ifdef USE_RPC_LOGGING");
593+
proxy("#ifdef CANOPY_USE_LOGGING");
594594
proxy("catch(std::exception& ex)");
595595
proxy("{{");
596596
proxy("RPC_ERROR(\"A proxy deserialisation error has occurred in an {} implementation in function {} "
@@ -681,7 +681,7 @@ namespace yas_generator
681681
stub("return rpc::error::STUB_DESERIALISATION_ERROR();");
682682
stub("}}");
683683
stub("}}");
684-
stub("#ifdef USE_RPC_LOGGING");
684+
stub("#ifdef CANOPY_USE_LOGGING");
685685
stub("catch(std::exception& ex)");
686686
stub("{{");
687687
stub("RPC_ERROR(\"A stub deserialisation error has occurred in an {} implementation in function {} {{}}\", "

rpc/include/rpc/internal/logger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#if defined(CANOPY_USE_THREAD_LOCAL_LOGGING) && !defined(_IN_ENCLAVE)
2020
// Use thread-local circular buffer logging
2121
#define RPC_LOG_BACKEND(level, message) rpc::thread_local_log(level, message, __FILE__, __LINE__, __FUNCTION__)
22-
#elif defined(USE_RPC_LOGGING)
22+
#elif defined(CANOPY_USE_LOGGING)
2323
// Use standard RPC logging
2424
#ifdef _IN_ENCLAVE
2525
#include <sgx_error.h>
@@ -45,7 +45,7 @@ extern "C"
4545
#endif
4646

4747
// Unified logging macros with levels (0=DEBUG, 1=TRACE, 2=INFO, 3=WARNING, 4=ERROR, 5=CRITICAL)
48-
#if defined(USE_RPC_LOGGING) || (defined(CANOPY_USE_THREAD_LOCAL_LOGGING) && !defined(_IN_ENCLAVE))
48+
#if defined(CANOPY_USE_LOGGING) || (defined(CANOPY_USE_THREAD_LOCAL_LOGGING) && !defined(_IN_ENCLAVE))
4949

5050
#ifdef _IN_ENCLAVE
5151
#include <fmt/format-inl.h>

rpc/include/rpc/internal/remote_pointer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ namespace rpc
21472147
else
21482148
{
21492149
// Remote object: establish optimistic reference (0→1 transition, async!)
2150-
#ifdef USE_RPC_LOGGING
2150+
#ifdef CANOPY_USE_LOGGING
21512151
// TELEMETRY: Check reference counts BEFORE establishing optimistic reference
21522152
long cb_shared_before = cb->shared_count_.load(std::memory_order_acquire);
21532153
long cb_optimistic_before = cb->optimistic_count_.load(std::memory_order_acquire);
@@ -2199,7 +2199,7 @@ namespace rpc
21992199
CO_RETURN err; // Failed to establish remote reference
22002200
}
22012201

2202-
#ifdef USE_RPC_LOGGING
2202+
#ifdef CANOPY_USE_LOGGING
22032203
// TELEMETRY: Check reference counts AFTER establishing optimistic reference
22042204
long cb_shared_after = cb->shared_count_.load(std::memory_order_acquire);
22052205
long cb_optimistic_after = cb->optimistic_count_.load(std::memory_order_acquire);
@@ -2275,7 +2275,7 @@ namespace rpc
22752275
else
22762276
{
22772277
// Remote object: establish optimistic reference (0→1 transition, async!)
2278-
#ifdef USE_RPC_LOGGING
2278+
#ifdef CANOPY_USE_LOGGING
22792279
// TELEMETRY: Check reference counts BEFORE establishing optimistic reference
22802280
long cb_shared_before = cb->shared_count_.load(std::memory_order_acquire);
22812281
long cb_optimistic_before = cb->optimistic_count_.load(std::memory_order_acquire);
@@ -2323,7 +2323,7 @@ namespace rpc
23232323
CO_RETURN err; // Failed (likely OBJECT_GONE)
23242324
}
23252325

2326-
#ifdef USE_RPC_LOGGING
2326+
#ifdef CANOPY_USE_LOGGING
23272327
// TELEMETRY: Check reference counts AFTER establishing optimistic reference
23282328
long cb_shared_after = cb->shared_count_.load(std::memory_order_acquire);
23292329
long cb_optimistic_after = cb->optimistic_count_.load(std::memory_order_acquire);

rpc/include/rpc/internal/thread_local_logger.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,4 @@ namespace rpc
143143

144144
} // namespace rpc
145145

146-
// Note: RPC_* macros are now defined in rpc/logger.h using the unified RPC_LOG_BACKEND approach
147-
148146
#endif // defined(CANOPY_USE_THREAD_LOCAL_LOGGING) && !defined(_IN_ENCLAVE)

rpc/src/pass_through.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ namespace rpc
253253
const std::vector<rpc::back_channel_entry>& in_back_channel,
254254
std::vector<rpc::back_channel_entry>& out_back_channel)
255255
{
256+
bool no_local_add_ref = !!(build_out_param_channel & add_ref_options::build_caller_route)
257+
&& !!(build_out_param_channel & add_ref_options::build_destination_route);
258+
256259
bool build_caller_channel = !!(build_out_param_channel & add_ref_options::build_caller_route);
257260
bool build_dest_channel = !!(build_out_param_channel & add_ref_options::build_destination_route)
258261
|| build_out_param_channel == add_ref_options::normal
@@ -261,6 +264,18 @@ namespace rpc
261264
std::shared_ptr<rpc::transport> caller_transport;
262265
std::shared_ptr<rpc::transport> destination_transport;
263266

267+
RPC_INFO("pass_through::add_ref zone={}, fwd={}, rev={}, dest={}, caller={}, options={}, build_dest={}, "
268+
"build_caller={}, no_local={}",
269+
zone_id_.get_val(),
270+
forward_destination_.get_val(),
271+
reverse_destination_.get_val(),
272+
destination_zone_id.get_val(),
273+
caller_zone_id.get_val(),
274+
static_cast<uint64_t>(build_out_param_channel),
275+
build_dest_channel,
276+
build_caller_channel,
277+
no_local_add_ref);
278+
264279
// Determine target transport based on destination_zone
265280
if (build_dest_channel)
266281
{
@@ -353,9 +368,7 @@ namespace rpc
353368

354369
// Use bitwise AND to check flags, not exact equality
355370
// because build_out_param_channel may have additional build flags
356-
if (!!(build_out_param_channel & add_ref_options::build_destination_route)
357-
&& !!(build_out_param_channel & add_ref_options::build_caller_route)
358-
&& destination_zone_id.as_caller() == caller_zone_id)
371+
if (no_local_add_ref && destination_zone_id.as_caller() == caller_zone_id)
359372
{
360373
// this is a passthrough addref and should not be included in either count
361374
}
@@ -395,6 +408,14 @@ namespace rpc
395408
const std::vector<rpc::back_channel_entry>& in_back_channel,
396409
std::vector<rpc::back_channel_entry>& out_back_channel)
397410
{
411+
RPC_INFO("pass_through::release zone={}, fwd={}, rev={}, dest={}, caller={}, options={}",
412+
zone_id_.get_val(),
413+
forward_destination_.get_val(),
414+
reverse_destination_.get_val(),
415+
destination_zone_id.get_val(),
416+
caller_zone_id.get_val(),
417+
static_cast<uint64_t>(options));
418+
398419
// Check if we're in the process of disconnecting
399420
if (status_.load(std::memory_order_acquire) == pass_through_status::DISCONNECTED)
400421
{
@@ -571,12 +592,11 @@ namespace rpc
571592
return;
572593
}
573594

574-
RPC_DEBUG(
575-
"trigger_self_destruction: Initiating pass-through destruction, forward_dest={}, reverse_dest={}, pt={}, "
576-
"shared={}, optimistic={}, function_count={}",
595+
RPC_INFO(
596+
"pass_through: deleting, zone={}, forward_dest={}, reverse_dest={}, shared={}, optimistic={}, active={}",
597+
zone_id_.get_val(),
577598
forward_destination_.get_val(),
578599
reverse_destination_.get_val(),
579-
(void*)this,
580600
shared_count_.load(),
581601
optimistic_count_.load(),
582602
function_count_.load());

rpc/src/service_proxy.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ namespace rpc
352352
// error handling here as the cleanup needs to happen anyway
353353
if (ret == rpc::error::OK())
354354
{
355-
RPC_DEBUG("Remote {} count = {} for object {}", is_optimistic ? "optimistic" : "shared", object_id.get_val());
355+
RPC_DEBUG("Remote {} for object {}", is_optimistic ? "optimistic" : "shared", object_id.get_val());
356356
}
357357
else if (is_optimistic && ret == rpc::error::OBJECT_NOT_FOUND())
358358
{
@@ -525,12 +525,7 @@ namespace rpc
525525
RPC_ASSERT(!new_proxy_added);
526526
auto ret = CO_AWAIT sp_release(
527527
object_id, is_optimistic ? rpc::release_options::optimistic : rpc::release_options::normal);
528-
if (ret == error::OK())
529-
{
530-
// // This is now safe because self_ref keeps us alive
531-
// release_external_ref();
532-
}
533-
else
528+
if (ret != error::OK())
534529
{
535530
RPC_ERROR("sp_release failed");
536531
CO_RETURN ret;

rpc/src/transport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ namespace rpc
246246

247247
#ifdef CANOPY_USE_TELEMETRY
248248
if (auto telemetry_service = rpc::get_telemetry_service(); telemetry_service)
249-
telemetry_service->on_transport_remove_passthrough(
249+
telemetry_service->on_transport_remove_destination(
250250
zone_id_, adjacent_zone_id_, lookup_val.zone1, lookup_val.zone2.as_caller());
251251
#endif
252252
}

0 commit comments

Comments
 (0)