mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-02 03:47:53 +08:00
add some log for acl_udp_server.c
This commit is contained in:
parent
1a35c94530
commit
3fff0e896d
@ -317,8 +317,9 @@ static void server_add_addrs(UDP_SERVER *server, ACL_HTABLE *addrs)
|
||||
ACL_VSTREAM *stream = server_bind_one(ptr);
|
||||
|
||||
if (stream == NULL) {
|
||||
acl_msg_error("%s(%d): bind %s error %s", __FUNCTION__,
|
||||
__LINE__, ptr, acl_last_serror());
|
||||
acl_msg_error("%s(%d), %s: bind %s error %s",
|
||||
__FILE__, __LINE__, __FUNCTION__,
|
||||
ptr, acl_last_serror());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -330,7 +331,8 @@ static void server_add_addrs(UDP_SERVER *server, ACL_HTABLE *addrs)
|
||||
acl_event_enable_read(server->event, stream, 0,
|
||||
udp_server_read, server);
|
||||
|
||||
acl_msg_info("bind %s addr ok, fd %d",
|
||||
acl_msg_info("%s(%d), %s: bind %s addr ok, fd %d",
|
||||
__FILE__, __LINE__, __FUNCTION__,
|
||||
ACL_VSTREAM_LOCAL(stream), SOCK(stream));
|
||||
}
|
||||
}
|
||||
@ -709,7 +711,8 @@ static ACL_VSTREAM *server_bind_one(const char *addr)
|
||||
|
||||
fd = acl_udp_bind(addr, flag);
|
||||
if (fd == ACL_SOCKET_INVALID) {
|
||||
acl_msg_warn("bind %s error %s", addr, acl_last_serror());
|
||||
acl_msg_warn("%s(%d), %s: bind %s error %s", __FILE__,
|
||||
__LINE__, __FUNCTION__, addr, acl_last_serror());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -220,27 +220,30 @@ static ACL_SOCKET find_bind(const char *addr, unsigned flag,
|
||||
}
|
||||
|
||||
ACL_SOCKET acl_sane_bind(const char *addr, unsigned flag,
|
||||
int socktype, int *family)
|
||||
int socktype, int *family_ptr)
|
||||
{
|
||||
ACL_SOCKET fd;
|
||||
int family = PF_UNSPEC;
|
||||
|
||||
if (acl_valid_ipv4_hostaddr(addr, 0)) {
|
||||
if (family) {
|
||||
*family = AF_INET;
|
||||
}
|
||||
fd = bind_addr(addr, flag, socktype, AF_INET);
|
||||
family = PF_INET;
|
||||
fd = bind_addr(addr, flag, socktype, PF_INET);
|
||||
} else if (acl_valid_ipv6_hostaddr(addr, 0)) {
|
||||
if (family) {
|
||||
*family = AF_INET6;
|
||||
}
|
||||
fd = bind_addr(addr, flag, socktype, AF_INET6);
|
||||
family = PF_INET6;
|
||||
fd = bind_addr(addr, flag, socktype, PF_INET6);
|
||||
} else {
|
||||
fd = find_bind(addr, flag, socktype, family);
|
||||
fd = find_bind(addr, flag, socktype, &family);
|
||||
}
|
||||
|
||||
if (family_ptr) {
|
||||
*family_ptr = family;
|
||||
}
|
||||
|
||||
if (fd == ACL_SOCKET_INVALID) {
|
||||
acl_msg_error("%s(%d): bind %s error %s",
|
||||
__FILE__, __LINE__, addr, acl_last_serror());
|
||||
acl_msg_error("%s(%d): bind %s error %s, family=%s",
|
||||
__FILE__, __LINE__, addr, acl_last_serror(),
|
||||
family == PF_INET ? "PF_INET" : (family == PF_INET6 ?
|
||||
"PF_INET6" : "UNKNOWN"));
|
||||
return ACL_SOCKET_INVALID;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user