Skip to content

Commit

Permalink
Reverting failing changes
Browse files Browse the repository at this point in the history
Revert Fix compile issue with pthreads in android commit
Revert Force abort hanging detached threads commit

The commits related to the shutdown cause crashes.
  • Loading branch information
Ana Rodrigues authored and Duarte Fonseca committed Oct 23, 2024
1 parent 90bd9e3 commit 6f711eb
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 817 deletions.
5 changes: 0 additions & 5 deletions documentation/vsomeipUserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,6 @@ Configuration file element explanation:
considered to be blocked (and an additional thread is used to execute pending
callbacks if max_dispatchers is configured greater than 0). The default value if not specified is 100ms.

* 'max_detached_thread_wait_time' (optional)

The maximum time in seconds that an application will wait for a detached dispatcher thread
to finish executing. The default value if not specified is 5s.

* 'threads' (optional)

The number of internal threads to process messages and events within an application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ struct application_configuration {
client_t client_;
std::size_t max_dispatchers_;
std::size_t max_dispatch_time_;
std::size_t max_detach_thread_wait_time_;
std::size_t thread_count_;
std::size_t request_debouncing_;
std::map<plugin_type_e, std::set<std::string> > plugins_;
Expand Down
1 change: 0 additions & 1 deletion implementation/configuration/include/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class configuration {

virtual std::size_t get_max_dispatchers(const std::string &_name) const = 0;
virtual std::size_t get_max_dispatch_time(const std::string &_name) const = 0;
virtual std::size_t get_max_detached_thread_wait_time(const std::string& _name) const = 0;
virtual std::size_t get_io_thread_count(const std::string &_name) const = 0;
virtual int get_io_thread_nice_level(const std::string &_name) const = 0;
virtual std::size_t get_request_debouncing(const std::string &_name) const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ class configuration_impl:

VSOMEIP_EXPORT std::size_t get_max_dispatchers(const std::string &_name) const;
VSOMEIP_EXPORT std::size_t get_max_dispatch_time(const std::string &_name) const;
VSOMEIP_EXPORT std::size_t get_max_detached_thread_wait_time(const std::string& _name) const;
VSOMEIP_EXPORT std::size_t get_io_thread_count(const std::string &_name) const;
VSOMEIP_EXPORT int get_io_thread_nice_level(const std::string &_name) const;
VSOMEIP_EXPORT std::size_t get_request_debouncing(const std::string &_name) const;
Expand Down
2 changes: 0 additions & 2 deletions implementation/configuration/include/internal.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@
#define VSOMEIP_MAX_DISPATCHERS 10
#define VSOMEIP_MAX_DISPATCH_TIME 100

#define VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS 5

#define VSOMEIP_REQUEST_DEBOUNCE_TIME 10
#define VSOMEIP_DEFAULT_STATISTICS_MAX_MSG 50
#define VSOMEIP_DEFAULT_STATISTICS_MIN_FREQ 50
Expand Down
2 changes: 0 additions & 2 deletions implementation/configuration/include/internal_android.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@
#define VSOMEIP_MAX_DISPATCHERS 10
#define VSOMEIP_MAX_DISPATCH_TIME 100

#define VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS 5

#define VSOMEIP_REQUEST_DEBOUNCE_TIME 10
#define VSOMEIP_DEFAULT_STATISTICS_MAX_MSG 50
#define VSOMEIP_DEFAULT_STATISTICS_MIN_FREQ 50
Expand Down
39 changes: 13 additions & 26 deletions implementation/configuration/src/configuration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,6 @@ void configuration_impl::load_application_data(
client_t its_id(VSOMEIP_CLIENT_UNSET);
std::size_t its_max_dispatchers(VSOMEIP_MAX_DISPATCHERS);
std::size_t its_max_dispatch_time(VSOMEIP_MAX_DISPATCH_TIME);
std::size_t its_max_detached_thread_wait_time(VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS);
std::size_t its_io_thread_count(VSOMEIP_DEFAULT_IO_THREAD_COUNT);
std::size_t its_request_debounce_time(VSOMEIP_REQUEST_DEBOUNCE_TIME);
std::map<plugin_type_e, std::set<std::string>> plugins;
Expand All @@ -1008,9 +1007,6 @@ void configuration_impl::load_application_data(
} else if (its_key == "max_dispatch_time") {
its_converter << std::dec << its_value;
its_converter >> its_max_dispatch_time;
} else if (its_key == "max_detached_thread_wait_time") {
its_converter << std::dec << its_value;
its_converter >> its_max_detached_thread_wait_time;
} else if (its_key == "threads") {
its_converter << std::dec << its_value;
its_converter >> its_io_thread_count;
Expand Down Expand Up @@ -1041,7 +1037,8 @@ void configuration_impl::load_application_data(
} catch (...) {
// intentionally empty
}
} else if (its_key == "has_session_handling") {
}
else if (its_key == "has_session_handling") {
has_session_handling = (its_value != "false");
}
}
Expand All @@ -1059,16 +1056,17 @@ void configuration_impl::load_application_data(
}
}

applications_[its_name] = {its_id,
its_max_dispatchers,
its_max_dispatch_time,
its_max_detached_thread_wait_time,
its_io_thread_count,
its_request_debounce_time,
plugins,
its_io_thread_nice_level,
its_debounces,
has_session_handling};
applications_[its_name] = {
its_id,
its_max_dispatchers,
its_max_dispatch_time,
its_io_thread_count,
its_request_debounce_time,
plugins,
its_io_thread_nice_level,
its_debounces
, has_session_handling
};
} else {
VSOMEIP_WARNING << "Multiple configurations for application "
<< its_name << ". Ignoring a configuration from "
Expand Down Expand Up @@ -3189,17 +3187,6 @@ std::size_t configuration_impl::get_max_dispatch_time(
return its_max_dispatch_time;
}

std::size_t configuration_impl::get_max_detached_thread_wait_time(const std::string& _name) const {
std::size_t its_max_detached_thread_wait_time = VSOMEIP_MAX_WAIT_TIME_DETACHED_THREADS;

if (auto found_application = applications_.find(_name);
found_application != applications_.end()) {
its_max_detached_thread_wait_time = found_application->second.max_detach_thread_wait_time_;
}

return its_max_detached_thread_wait_time;
}

bool configuration_impl::has_session_handling(const std::string &_name) const {

bool its_value(true);
Expand Down
25 changes: 1 addition & 24 deletions implementation/runtime/include/application_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

#include <atomic>
#include <condition_variable>
#include <cstdint>
#include <deque>
#include <future>
#include <map>
#include <mutex>
#include <set>
Expand All @@ -19,12 +17,6 @@
#include <unordered_map>
#include <vector>

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <processthreadsapi.h>
#endif

#include <boost/asio/executor_work_guard.hpp>
#include <boost/asio/signal_set.hpp>
Expand Down Expand Up @@ -313,6 +305,7 @@ class application_impl: public application,
instance_t _instance, const availability_state_handler_t &_handler,
major_version_t _major, minor_version_t _minor);


void main_dispatch();
void dispatch();
void invoke_handler(std::shared_ptr<sync_handler> &_handler);
Expand Down Expand Up @@ -352,10 +345,6 @@ class application_impl: public application,
void invoke_availability_handler(service_t _service, instance_t _instance,
major_version_t _major, minor_version_t _minor);

void increment_active_threads();
void decrement_active_threads();
std::uint16_t get_active_threads() const;

using availability_state_t = std::map<service_t, std::map<instance_t,
std::map<major_version_t, std::map<minor_version_t, availability_state_e>>>>;

Expand Down Expand Up @@ -457,23 +446,11 @@ class application_impl: public application,
// Mutex to protect access to dispatchers_ & elapsed_dispatchers_
mutable std::mutex dispatcher_mutex_;

// Map of promises/futures to check status of dispatcher threads
#ifdef _WIN32
std::map<std::thread::id, std::tuple<HANDLE, std::future<void>>> dispatchers_control_;
#else
std::map<std::thread::id, std::tuple<pthread_t, std::future<void>>> dispatchers_control_;
#endif

// Condition to wakeup the dispatcher thread
mutable std::condition_variable dispatcher_condition_;
std::size_t max_dispatchers_;
std::size_t max_dispatch_time_;

// Counter for dispatcher threads
std::atomic<uint16_t> dispatcher_counter_;

std::size_t max_detached_thread_wait_time;

std::condition_variable stop_cv_;
std::mutex start_stop_mutex_;
bool stopped_;
Expand Down
Loading

0 comments on commit 6f711eb

Please sign in to comment.