aboutsummaryrefslogtreecommitdiffstats
path: root/trial/direct_bt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-05-12 02:10:35 +0200
committerSven Gothel <[email protected]>2022-05-12 02:10:35 +0200
commit42a8aac5a30f8e77912311e91167464fbf5be6d4 (patch)
treea2667cfbf7d4b18acb41af4cab9a310c8b59fc2b /trial/direct_bt
parent155fb835425f59a2df9ffc4f379a8e87dc2f4a3f (diff)
Trial C++: Query BaseDBTClientServer::is_timedout() having an atomic flag set by timout_func() instead of abort() producing a core dump
Diffstat (limited to 'trial/direct_bt')
-rw-r--r--trial/direct_bt/dbt_base_client_server.hpp15
-rw-r--r--trial/direct_bt/dbt_client_server1x.hpp3
2 files changed, 11 insertions, 7 deletions
diff --git a/trial/direct_bt/dbt_base_client_server.hpp b/trial/direct_bt/dbt_base_client_server.hpp
index 9182dd24..5675f56e 100644
--- a/trial/direct_bt/dbt_base_client_server.hpp
+++ b/trial/direct_bt/dbt_base_client_server.hpp
@@ -41,12 +41,13 @@ class BaseDBTClientServer {
jau::fraction_i64 test_timeout = 0_s;
- jau::simple_timer timeour_timer = jau::simple_timer("DBTTrial-Timeout", 1_s /* shutdown timeout */);
+ jau::simple_timer timeout_timer = jau::simple_timer("DBTTrial-Timeout", 1_s /* shutdown timeout */);
+ jau::sc_atomic_bool timedout = false;
jau::fraction_i64 timeout_func(jau::simple_timer& timer) {
if( !timer.shall_stop() ) {
fprintf(stderr, "\n***** DBTTrial Error: Timeout %s sec -> abort *****\n\n", test_timeout.to_string(true).c_str());
- abort();
+ timedout = true;
}
return 0_s;
}
@@ -62,7 +63,7 @@ class BaseDBTClientServer {
}
void close() {
- timeour_timer.stop();
+ timeout_timer.stop();
BTManager& manager = BTManager::get();
#if 0
jau::darray<BTAdapterRef> adapters = manager.getAdapters();
@@ -84,6 +85,8 @@ class BaseDBTClientServer {
jau::fraction_i64 get_timeout_value() const { return test_timeout; }
+ bool is_timedout() const noexcept { return timedout; }
+
/**
* Ensure
* - all adapter are powered off
@@ -96,7 +99,7 @@ class BaseDBTClientServer {
* - all adapter are powered off
*/
void setupTest(const jau::fraction_i64 timeout = 0_s) {
- timeour_timer.stop();
+ timeout_timer.stop();
test_timeout = timeout;
BTManager& manager = BTManager::get();
jau::darray<BTAdapterRef> adapters = manager.getAdapters();
@@ -110,7 +113,7 @@ class BaseDBTClientServer {
BTDeviceRegistry::clearProcessingDevices();
BTSecurityRegistry::clear();
if( !timeout.is_zero() ) {
- timeour_timer.start(timeout, jau::bindMemberFunc(this, &BaseDBTClientServer::timeout_func));
+ timeout_timer.start(timeout, jau::bindMemberFunc(this, &BaseDBTClientServer::timeout_func));
}
}
@@ -122,7 +125,7 @@ class BaseDBTClientServer {
* - clear BTSecurityRegistry
*/
void cleanupTest() {
- timeour_timer.stop();
+ timeout_timer.stop();
test_timeout = 0_s;
BTManager& manager = BTManager::get();
jau::darray<BTAdapterRef> adapters = manager.getAdapters();
diff --git a/trial/direct_bt/dbt_client_server1x.hpp b/trial/direct_bt/dbt_client_server1x.hpp
index c239cb7c..2c42c94e 100644
--- a/trial/direct_bt/dbt_client_server1x.hpp
+++ b/trial/direct_bt/dbt_client_server1x.hpp
@@ -167,7 +167,8 @@ class DBTClientServer1x {
}
max_connections_hit = ( protocolSessionCount * max_connections_per_session ) <= server->getDisconnectCount();
test_duration = ( jau::getMonotonicTime() - t0 ).to_fraction_i64();
- timeout = 0_s < timeout_value && timeout_value <= test_duration + timeout_preempt_diff; // let's timeout here before our timeout timer
+ timeout = framework.is_timedout() ||
+ ( 0_s < timeout_value && timeout_value <= test_duration + timeout_preempt_diff ); // let's timeout here before our timeout timer
if( !done && !max_connections_hit && !timeout ) {
jau::sleep_for( 88_ms );
}