Changing signature of numeric_name from numeric_name(addrinfo *addr)
to numeric_name(const struct sockaddr *sa, socklen_t salen) to remove dependency on addrinfo struct.
This commit is contained in:
parent
b773d63b92
commit
1bdf664f4d
|
@ -1536,7 +1536,7 @@ int start_listen(struct ev_loop *loop, Sessions *sessions,
|
||||||
new ListenEventHandler(sessions, fd, acceptor);
|
new ListenEventHandler(sessions, fd, acceptor);
|
||||||
|
|
||||||
if (config->verbose) {
|
if (config->verbose) {
|
||||||
std::string s = util::numeric_name(rp);
|
std::string s = util::numeric_name(rp->ai_addr, rp->ai_addrlen);
|
||||||
std::cout << (rp->ai_family == AF_INET ? "IPv4" : "IPv6") << ": listen "
|
std::cout << (rp->ai_family == AF_INET ? "IPv4" : "IPv6") << ": listen "
|
||||||
<< s << ":" << config->port << std::endl;
|
<< s << ":" << config->port << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -674,13 +674,13 @@ int HttpClient::noop() { return 0; }
|
||||||
void HttpClient::on_connect_fail() {
|
void HttpClient::on_connect_fail() {
|
||||||
if (state == STATE_IDLE) {
|
if (state == STATE_IDLE) {
|
||||||
std::cerr << "[ERROR] Could not connect to the address "
|
std::cerr << "[ERROR] Could not connect to the address "
|
||||||
<< util::numeric_name(cur_addr) << std::endl;
|
<< util::numeric_name(cur_addr->ai_addr, cur_addr->ai_addrlen) << std::endl;
|
||||||
}
|
}
|
||||||
auto cur_state = state;
|
auto cur_state = state;
|
||||||
disconnect();
|
disconnect();
|
||||||
if (cur_state == STATE_IDLE) {
|
if (cur_state == STATE_IDLE) {
|
||||||
if (initiate_connection() == 0) {
|
if (initiate_connection() == 0) {
|
||||||
std::cerr << "Trying next address " << util::numeric_name(cur_addr)
|
std::cerr << "Trying next address " << util::numeric_name(cur_addr->ai_addr, cur_addr->ai_addrlen)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -688,9 +688,9 @@ bool numeric_host(const char *hostname) {
|
||||||
|
|
||||||
// Returns numeric address string of |addr|. If getnameinfo() is
|
// Returns numeric address string of |addr|. If getnameinfo() is
|
||||||
// failed, "unknown" is returned.
|
// failed, "unknown" is returned.
|
||||||
std::string numeric_name(addrinfo *addr) {
|
std::string numeric_name(const struct sockaddr *sa, socklen_t salen) {
|
||||||
char host[NI_MAXHOST];
|
char host[NI_MAXHOST];
|
||||||
auto rv = getnameinfo(addr->ai_addr, addr->ai_addrlen, host, sizeof(host),
|
auto rv = getnameinfo(sa, salen, host, sizeof(host),
|
||||||
nullptr, 0, NI_NUMERICHOST);
|
nullptr, 0, NI_NUMERICHOST);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
|
|
|
@ -418,7 +418,7 @@ void write_uri_field(std::ostream &o, const char *uri, const http_parser_url &u,
|
||||||
|
|
||||||
bool numeric_host(const char *hostname);
|
bool numeric_host(const char *hostname);
|
||||||
|
|
||||||
std::string numeric_name(addrinfo *addr);
|
std::string numeric_name(const struct sockaddr *sa, socklen_t salen);
|
||||||
|
|
||||||
// Opens |path| with O_APPEND enabled. If file does not exist, it is
|
// Opens |path| with O_APPEND enabled. If file does not exist, it is
|
||||||
// created first. This function returns file descriptor referring the
|
// created first. This function returns file descriptor referring the
|
||||||
|
|
Loading…
Reference in New Issue