let get_local_addr_ipv4 return error code
This commit is contained in:
7
deps/oblib/src/lib/net/ob_net_util.cpp
vendored
7
deps/oblib/src/lib/net/ob_net_util.cpp
vendored
@ -95,10 +95,9 @@ int ObNetUtil::get_local_addr_ipv6(const char *dev_name, char *ipv6, int len,
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t ObNetUtil::get_local_addr_ipv4(const char *dev_name)
|
||||
int ObNetUtil::get_local_addr_ipv4(const char *dev_name, uint32_t &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
uint32_t ret_addr = 0;
|
||||
struct ifaddrs *ifa = nullptr, *ifa_tmp = nullptr;
|
||||
|
||||
if (nullptr == dev_name) {
|
||||
@ -116,7 +115,7 @@ uint32_t ObNetUtil::get_local_addr_ipv4(const char *dev_name)
|
||||
0 == strcmp(ifa_tmp->ifa_name, dev_name)) {
|
||||
has_found = true;
|
||||
struct sockaddr_in *in = (struct sockaddr_in *) ifa_tmp->ifa_addr;
|
||||
ret_addr = in->sin_addr.s_addr;
|
||||
addr = in->sin_addr.s_addr;
|
||||
} // if end
|
||||
ifa_tmp = ifa_tmp->ifa_next;
|
||||
} // while end
|
||||
@ -132,7 +131,7 @@ uint32_t ObNetUtil::get_local_addr_ipv4(const char *dev_name)
|
||||
freeifaddrs(ifa);
|
||||
}
|
||||
|
||||
return ret_addr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string ObNetUtil::addr_to_string(uint64_t ipport)
|
||||
|
||||
2
deps/oblib/src/lib/net/ob_net_util.h
vendored
2
deps/oblib/src/lib/net/ob_net_util.h
vendored
@ -49,7 +49,7 @@ private:
|
||||
static bool is_wild_match(const common::ObString &client_ip, const common::ObString &host_name);
|
||||
public:
|
||||
static int get_local_addr_ipv6(const char *dev_name, char *ipv6, int len, bool *is_linklocal = nullptr);
|
||||
static uint32_t get_local_addr_ipv4(const char *dev_name);
|
||||
static int get_local_addr_ipv4(const char *dev_name, uint32_t &addr);
|
||||
static std::string addr_to_string(uint64_t ipport);
|
||||
static uint64_t ip_to_addr(uint32_t ip, int port);
|
||||
// get ipv4 by hostname, no need free the returned value
|
||||
|
||||
@ -118,7 +118,7 @@ int ObRpcProtocolProcessor::decode(easy_message_t *ms, ObRpcPacket *&pkt)
|
||||
bool is_demand_data_enough = false;
|
||||
int64_t preceding_data_len = 0;
|
||||
int64_t decode_data_len = 0;
|
||||
common::ObTimeGuard timeguard("ObRpcProtocolProcessor::encode", common::OB_EASY_HANDLER_COST_TIME);
|
||||
common::ObTimeGuard timeguard("ObRpcProtocolProcessor::decode", common::OB_EASY_HANDLER_COST_TIME);
|
||||
if (OB_FAIL(resolve_packet_type(timeguard, ms, is_demand_data_enough, preceding_data_len, decode_data_len))) {
|
||||
LOG_ERROR("failed to resolve packet type", K(ret));
|
||||
} else if (is_demand_data_enough) {
|
||||
|
||||
Reference in New Issue
Block a user