Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BugFix: fix the following bugs #85

Merged
merged 1 commit into from
Dec 1, 2023
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
1 change: 1 addition & 0 deletions trpc/client/service_proxy_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void ServiceProxyManager::SetOptionFromConfig(const ServiceProxyConfig& proxy_co
option->is_reconnection = proxy_conf.is_reconnection;
option->connect_timeout = proxy_conf.connect_timeout;
option->allow_reconnect = proxy_conf.allow_reconnect;
option->threadmodel_type_name = proxy_conf.threadmodel_type;
option->threadmodel_instance_name = proxy_conf.threadmodel_instance_name;
option->service_filters = proxy_conf.service_filters;

Expand Down
4 changes: 4 additions & 0 deletions trpc/client/service_proxy_option_setter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void SetDefaultOption(const std::shared_ptr<ServiceProxyOption>& option) {
option->is_reconnection = kDefaultIsReconnection;
option->connect_timeout = kDefaultConnectTimeout;
option->allow_reconnect = kDefaultAllowReconnect;
option->threadmodel_type_name = kDefaultThreadmodelType;
option->threadmodel_instance_name = "";
option->support_pipeline = kDefaultSupportPipeline;
}
Expand Down Expand Up @@ -186,6 +187,9 @@ void SetSpecifiedOption(const ServiceProxyOption* option_ptr, const std::shared_
auto allow_reconnect = GetValidInput<bool>(option_ptr->allow_reconnect, kDefaultAllowReconnect);
SetOutputByValidInput<bool>(allow_reconnect, option->allow_reconnect);

auto threadmodel_type_name = GetValidInput<std::string>(option_ptr->threadmodel_type_name, kDefaultThreadmodelType);
SetOutputByValidInput<std::string>(threadmodel_type_name, option->threadmodel_type_name);

auto threadmodel_instance_name = GetValidInput<std::string>(option_ptr->threadmodel_instance_name, "");
SetOutputByValidInput<std::string>(threadmodel_instance_name, option->threadmodel_instance_name);

Expand Down
2 changes: 2 additions & 0 deletions trpc/common/config/client_conf_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct convert<trpc::ServiceProxyConfig> {
node["recv_buffer_size"] = proxy_config.recv_buffer_size;
node["send_queue_capacity"] = proxy_config.send_queue_capacity;
node["send_queue_timeout"] = proxy_config.send_queue_timeout;
node["threadmodel_type"] = proxy_config.threadmodel_type;
node["threadmodel_instance_name"] = proxy_config.threadmodel_instance_name;
node["selector_name"] = proxy_config.selector_name;
node["namespace"] = proxy_config.namespace_;
Expand Down Expand Up @@ -101,6 +102,7 @@ struct convert<trpc::ServiceProxyConfig> {
if (node["recv_buffer_size"]) proxy_config.recv_buffer_size = node["recv_buffer_size"].as<uint32_t>();
if (node["send_queue_capacity"]) proxy_config.send_queue_capacity = node["send_queue_capacity"].as<uint32_t>();
if (node["send_queue_timeout"]) proxy_config.send_queue_timeout = node["send_queue_timeout"].as<uint32_t>();
if (node["threadmodel_type"]) proxy_config.threadmodel_type = node["threadmodel_type"].as<std::string>();
if (node["threadmodel_instance_name"])
proxy_config.threadmodel_instance_name = node["threadmodel_instance_name"].as<std::string>();
if (node["selector_name"]) proxy_config.selector_name = node["selector_name"].as<std::string>();
Expand Down
4 changes: 4 additions & 0 deletions trpc/common/config/server_conf_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct convert<trpc::ServiceConfig> {
node["recv_buffer_size"] = service_config.recv_buffer_size;
node["send_queue_capacity"] = service_config.send_queue_capacity;
node["send_queue_timeout"] = service_config.send_queue_timeout;
node["threadmodel_type"] = service_config.threadmodel_type;
node["threadmodel_instance_name"] = service_config.threadmodel_instance_name;
node["accept_thread_num"] = service_config.accept_thread_num;
node["stream_read_timeout"] = service_config.stream_read_timeout;
Expand Down Expand Up @@ -122,6 +123,9 @@ struct convert<trpc::ServiceConfig> {
if (node["send_queue_timeout"]) {
service_config.send_queue_timeout = node["send_queue_timeout"].as<uint32_t>();
}
if (node["threadmodel_type"]) {
service_config.threadmodel_type = node["threadmodel_type"].as<std::string>();
}
if (node["threadmodel_instance_name"]) {
service_config.threadmodel_instance_name = node["threadmodel_instance_name"].as<std::string>();
}
Expand Down
1 change: 1 addition & 0 deletions trpc/server/trpc_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void TrpcServer::BuildServiceAdapterOption(const ServiceConfig& config, ServiceA
option.send_queue_capacity = config.send_queue_capacity;
option.send_queue_timeout = config.send_queue_timeout;
option.accept_thread_num = config.accept_thread_num;
option.threadmodel_type = config.threadmodel_type;
option.threadmodel_instance_name = config.threadmodel_instance_name;
option.stream_read_timeout = config.stream_read_timeout;
option.stream_max_window_size = config.stream_max_window_size;
Expand Down
1 change: 1 addition & 0 deletions trpc/tools/gdb_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ RIP 0x00000000009249d4 RBP 0x00007f598e5fe8d0 RSP 0x00007f598e5fe880
Found 2 fiber(s) in total.
```

Note: for the production environment, you can use the following command to minimize the impact of debugging on the running service (although this command can still cause a second-level service suspension): `gdb --pid <PID> --eval-command='source gdb_fiber_plugin.py' --eval-command='set pagination off' --eval-command='list-fibers' --batch`.
5 changes: 5 additions & 0 deletions trpc/tools/gdb_plugin/gdb_fiber_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __init__(self, inferior, fiber_entity_ptr):
saved_state = inferior.read_memory(state_save_area, 0x40)
except GdbMemoryError:
saved_state = '\x00' * 0x40
return None
# @sa: fiber/detail/x86_64/jump_context.S
#
# +---------------------------------------------------------------+
Expand Down Expand Up @@ -327,6 +328,8 @@ def try_extract_fiber(inferior, active_frames, offset):
try:
# It's a fiber stack. Otherwise we shouldn't have been called.
fiber = Fiber(inferior, offset - FIBER_STACK_RESERVED_SIZE)
if fiber is None:
return None

if fiber.stack_top == fiber.stack_bottom:
# Master fiber.
Expand Down Expand Up @@ -430,6 +433,8 @@ def extract_call_stack(inferior, rip, rbp):
yield rip # Hmmm...
try:
while True:
if rbp == 0:
return
ip = struct.unpack('Q', inferior.read_memory(rbp + 8, 8))[0]
if ip == 0:
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@
namespace trpc {

FutureTcpConnectorGroupManager::FutureTcpConnectorGroupManager(const Options& options)
: FutureConnectorGroupManager(options) {
if (options_.trans_info->is_complex_conn) {
shared_msg_timeout_handler_ =
std::make_unique<FutureConnComplexMessageTimeoutHandler>(options_.trans_info->rsp_dispatch_function);
TRPC_ASSERT(shared_msg_timeout_handler_ != nullptr);
}
}
: FutureConnectorGroupManager(options) {}

void FutureTcpConnectorGroupManager::Stop() {
if (options_.trans_info->is_complex_conn && timer_id_ != kInvalidTimerId) {
Expand All @@ -52,6 +46,9 @@ void FutureTcpConnectorGroupManager::Destroy() {
bool FutureTcpConnectorGroupManager::CreateTimer() {
if (!is_create_timer_) {
if (options_.trans_info->is_complex_conn) {
shared_msg_timeout_handler_ =
std::make_unique<FutureConnComplexMessageTimeoutHandler>(options_.trans_info->rsp_dispatch_function);
TRPC_ASSERT(shared_msg_timeout_handler_ != nullptr);
auto timeout_check_interval = options_.trans_info->request_timeout_check_interval;
timer_id_ = options_.reactor->AddTimerAfter(
0, timeout_check_interval, [this]() { shared_msg_timeout_handler_->DoTimeout(); });
Expand Down
2 changes: 1 addition & 1 deletion trpc/transport/client/future/future_transport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ uint16_t FutureTransport::SelectTransportAdapter(CTransportReqMsg* msg, uint16_t
bool FutureTransport::IsSameIOThread(uint16_t index) {
auto* current_thread = WorkerThread::GetCurrentWorkerThread();
if (current_thread && current_thread->Role() != kHandle) {
if (index == GetLogicId(current_thread)) {
if ((index == GetLogicId(current_thread)) && (options_.thread_model->GroupId() == current_thread->GroupId())) {
return true;
}
}
Expand Down