IPv6 Patch
Brian Aker
brian at tangent.org
Wed Jan 30 19:07:54 UTC 2008
Hi!
On Jan 29, 2008, at 11:54 PM, Tomash Brechko wrote:
> That's exactly the point. The user have the control with the -l
> option. And if I specify some name, I expect it to be resolved to all
> addresses (for one address I would simply specify it as is). I doubt
> Drepper's paper is wrong with this respect. Also, with IPv6 a single
Drepper's paper is not wrong, it just does not think through the
actions of poor DNS entries.
One thought I had this morning was perhaps toss an error if ai->next
shows that there are multiple binding addresses.
> AI_ADDRCONFIG is required to skip the addresses when they are reported
> by DNS but the host doesn't bind them to any interface. As for the
> rest, I didn't mean you should combine UPD and TCP. What I mean is
> that there's no point to disable IPv6 for UDP as you did, and no point
> to explicitly specify IPPROTO_* along with SOCK_*.
OSX 10.5 has issues with IPv6 and binding for UDP right now, which is
why I left it that way (but then 10.5).
I've never found an authoritative that says you can get away with just
setting IPPROT and not SOCK (or vice versa).
>>> It should be
>>>
>>> if (error != 0) {
>>> if (error != EAI_SYSTEM)
>>> fprintf(stderr, "getaddrinfo(): %s\n",
>>> gai_strerror(error));
>>> else
>>> perror("getaddrinfo()");
>>>
>>> return -1;
>>> }
>>
>> All errors returned by getaddrinfo() are handled by gai_strerror().
>> Running perror in the way you suggest above will get you a haphazard
>> message of "SUCCESS" from perror(). Just let the error fall to
>> gai_strerror().
>
> "SUCCESS" can't be ever reported, the code above runs perror() only
> when getaddrinfo() returns EAI_SYSTEM. gai_strerror(EAI_SYSTEM) will
> return "System error", while perror() will be more specific. Here's
> what man page says:
>
> EAI_SYSTEM
> Other system error, check errno for details.
>
> And the code above "checks" errno with perror().
Ok, extra error information can not hurt (though I suspect some
systems will report SUCCESS via this).
>>> You have lots of premature returns where you better to do
>>> freeaddrinfo() too, just for the case ;).
>>
>>
>> That is how the program is structured. Look at how the other exit
>> points are done.
>
> Exactly because of this. On other exit points the code is careful to
> close the socket, so you should do your cleanup as well.
Ok.
Cheers,
-Brian
--
_______________________________________________________
Brian "Krow" Aker, brian at tangent.org
Seattle, Washington
http://krow.net/ <-- Me
http://tangent.org/ <-- Software
http://exploitseattle.com/ <-- Fun
_______________________________________________________
You can't grep a dead tree.
More information about the memcached
mailing list