Permalink
Browse files

Do the right thing if someone has a broken IPV6 stack which is only I…

…PV6.
  • Loading branch information...
BrianAker authored and dustin committed Sep 6, 2008
1 parent 18474d5 commit 810c13bceed2d2e96449f285dc53913861cc4c0a
Showing with 11 additions and 2 deletions.
  1. +11 −2 memcached.c
View
@@ -2481,12 +2481,10 @@ static int server_socket(const int port, const bool is_udp) {
hints.ai_flags = AI_PASSIVE|AI_ADDRCONFIG;
if (is_udp)
{
- hints.ai_protocol = IPPROTO_UDP;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_family = AF_INET; /* This left here because of issues with OSX 10.5 */
} else {
hints.ai_family = AF_UNSPEC;
- hints.ai_protocol = IPPROTO_TCP;
hints.ai_socktype = SOCK_STREAM;
}
@@ -2508,6 +2506,17 @@ static int server_socket(const int port, const bool is_udp) {
return 1;
}
+#ifdef IPV6_V6ONLY
+ if (next->ai_family == AF_INET6) {
+ error = setsockopt(sfd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &flags, sizeof(flags));
+ if (error != 0) {
+ perror("setsockopt");
+ close(sfd);
+ continue;
+ }
+ }
+#endif
+
setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, (void *)&flags, sizeof(flags));
if (is_udp) {
maximize_sndbuf(sfd);

0 comments on commit 810c13b

Please sign in to comment.