Skip to content

Commit

Permalink
liguohao improve
Browse files Browse the repository at this point in the history
  • Loading branch information
GehaFearless committed Jan 29, 2024
1 parent 62ef062 commit e4fd3a6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/replica/replica_2pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include "replica_stub.h"
#include "runtime/api_layer1.h"
#include "runtime/rpc/dns_resolver.h"
#include "runtime/rpc/network.h"
#include "runtime/rpc/rpc_address.h"
#include "runtime/rpc/rpc_host_port.h"
#include "runtime/rpc/rpc_message.h"
Expand Down
1 change: 0 additions & 1 deletion src/replica/replica_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
// IWYU pragma: no_include <ext/alloc_traits.h>
#include <fmt/core.h>
#include <fmt/format.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
Expand Down
11 changes: 4 additions & 7 deletions src/runtime/rpc/rpc_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "common/gpid.h"
#include "runtime/api_layer1.h"
#include "runtime/global_config.h"
#include "runtime/rpc/dns_resolver.h"
#include "runtime/rpc/group_address.h"
#include "runtime/rpc/group_host_port.h"
#include "runtime/rpc/network.h"
Expand Down Expand Up @@ -133,10 +132,8 @@ bool rpc_client_matcher::on_recv_reply(network *net, uint64_t key, message_ex *r
// if this is pure client (no server port assigned), we can only do fake forwarding,
// in this case, the server will return ERR_FORWARD_TO_OTHERS
if (err == ERR_FORWARD_TO_OTHERS) {
host_port hp;
::dsn::unmarshall((dsn::message_ex *)reply, hp);
std::shared_ptr<dns_resolver> resolver = std::make_shared<dns_resolver>();
auto addr = resolver->resolve_address(hp);
rpc_address addr;
::dsn::unmarshall((dsn::message_ex *)reply, addr);

// handle the case of forwarding to itself where addr == req->to_address.
DCHECK_NE_MSG(
Expand All @@ -153,7 +150,7 @@ bool rpc_client_matcher::on_recv_reply(network *net, uint64_t key, message_ex *r
case GRPC_TO_LEADER:
if (req->server_address.group_address()->is_update_leader_automatically()) {
req->server_address.group_address()->set_leader(addr);
req->server_host_port.group_host_port()->set_leader(hp);
req->server_host_port.group_host_port()->set_leader(host_port(addr));
}
break;
default:
Expand Down Expand Up @@ -854,7 +851,7 @@ void rpc_engine::forward(message_ex *request, rpc_address address)
// we therefore cannot really do the forwarding but fake it
if (request->header->from_address.port() <= MAX_CLIENT_PORT) {
auto resp = request->create_response();
::dsn::marshall(resp, host_port(address));
::dsn::marshall(resp, address);
::dsn::task::get_current_rpc()->reply(resp, ::dsn::ERR_FORWARD_TO_OTHERS);
}

Expand Down
4 changes: 3 additions & 1 deletion src/runtime/rpc/rpc_host_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ error_s GetAddrInfo(const std::string &hostname, const addrinfo &hints, AddrInfo
host_port::host_port(std::string host, uint16_t port)
: _host(std::move(host)), _port(port), _type(HOST_TYPE_IPV4)
{
CHECK_NE_MSG(rpc_address::ipv4_from_host(_host.c_str()), 0, "invalid hostname: {}", _host);
if (_host != "0.0.0.0") {
CHECK_NE_MSG(rpc_address::ipv4_from_host(_host.c_str()), 0, "invalid hostname: {}", _host);
}
}

host_port::host_port(rpc_address addr)
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/rpc/rpc_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ class message_ex : public ref_counter, public extensible_object<message_ex, 4>
rpc_session_ptr io_session; // send/recv session
rpc_address to_address; // always ipv4/v6 address, it is the to_node's net address
rpc_address server_address; // used by requests, and may be of uri/group address
host_port to_host_port; // fqdn from 'to_address', older versions use fqdn as net
host_port server_host_port; // fqdn from 'server_address', older versions use fqdn as net
host_port to_host_port; // fqdn from 'to_address'
host_port server_host_port; // fqdn from 'server_address'
dsn::task_code local_rpc_code;
network_header_format hdr_format;
int send_retry_count;
Expand Down
1 change: 0 additions & 1 deletion src/server/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
io_service_worker_count = 4
; how many connections can be established from one ip address to a server(both replica and meta), 0 means no threshold
conn_threshold_per_ip = 0
use_cache_resolve_hostname = true

; specification for each thread pool
[threadpool..default]
Expand Down
6 changes: 3 additions & 3 deletions src/server/test/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,15 @@ profiler::cancelled = false
;profiler::timeout.qps = false

[meta_server]
server_list = 127.0.0.1:34701
server_list = 0.0.0.0:34701

[duplication-group]
onebox = 1
onebox2 = 2

[pegasus.clusters]
onebox = 127.0.0.1:34701
onebox2 = 127.0.0.1:35701
onebox = 0.0.0.0:34701
onebox2 = 0.0.0.0:35701

[pegasus.collector]
enable_detect_hotkey = true

0 comments on commit e4fd3a6

Please sign in to comment.