mirror of
https://github.com/samhocevar/rinetd.git
synced 2025-03-22 15:50:08 +08:00
Fix getaddrinfo() hint initialisation issues.
This commit is contained in:
parent
a5905bbcea
commit
f7cd21f91f
@ -276,6 +276,7 @@ void addServer(char *bindAddress, char *bindPort, protocolType bindProto,
|
|||||||
struct addrinfo hints =
|
struct addrinfo hints =
|
||||||
{
|
{
|
||||||
.ai_family = AF_UNSPEC,
|
.ai_family = AF_UNSPEC,
|
||||||
|
.ai_protocol = bindProto == protoTcp ? IPPROTO_TCP : IPPROTO_UDP,
|
||||||
.ai_socktype = bindProto == protoTcp ? SOCK_STREAM : SOCK_DGRAM,
|
.ai_socktype = bindProto == protoTcp ? SOCK_STREAM : SOCK_DGRAM,
|
||||||
.ai_flags = AI_PASSIVE,
|
.ai_flags = AI_PASSIVE,
|
||||||
};
|
};
|
||||||
@ -287,9 +288,7 @@ void addServer(char *bindAddress, char *bindPort, protocolType bindProto,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (struct addrinfo *it = servinfo; it; it = it->ai_next) {
|
for (struct addrinfo *it = servinfo; it; it = it->ai_next) {
|
||||||
si.fd = socket(it->ai_family,
|
si.fd = socket(it->ai_family, it->ai_socktype, it->ai_protocol);
|
||||||
bindProto == protoTcp ? SOCK_STREAM : SOCK_DGRAM,
|
|
||||||
bindProto == protoTcp ? IPPROTO_TCP : IPPROTO_UDP);
|
|
||||||
if (si.fd == INVALID_SOCKET) {
|
if (si.fd == INVALID_SOCKET) {
|
||||||
syslog(LOG_ERR, "couldn't create server socket! (%m)\n");
|
syslog(LOG_ERR, "couldn't create server socket! (%m)\n");
|
||||||
freeaddrinfo(servinfo);
|
freeaddrinfo(servinfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user