[FFmpeg-devel] [PATCH] Enable proper IPv6 functions on windows
Fri Jan 22 19:02:24 CET 2010
On Fri, Jan 22, 2010 at 10:50:03AM -0500, Ronald S. Bultje wrote:
> On Fri, Jan 22, 2010 at 10:40 AM, Martin Storsj? <martin at martin.st> wrote:
> > On Fri, 22 Jan 2010, Ronald S. Bultje wrote:
> >> > + ? ?int (WSAAPI *win_getnameinfo)(const struct sockaddr *sa, socklen_t salen,
> >> > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?char *host, DWORD hostlen,
> >> > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?char *serv, DWORD servlen, int flags);
> >> > + ? ?HMODULE ws2mod = GetModuleHandle("ws2_32.dll");
> >> > + ? ?win_getnameinfo = GetProcAddress(ws2mod, "getnameinfo");
> >> > + ? ?if (win_getnameinfo)
> >> > + ? ? ? ?return win_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
> >> Sorry, I didn't follow the discussion very much...
> >> Shouldn't the function pointer variable (in all functions) not be
> >> static? Now you load it every time which sounds like a huge
> >> time-waster to me. Otherwise looks ok to me.
> > I guess that would be ok, too. Theoretically, it wouldn't be totally
> > thread safe, but for all practical matters I think it would be ok.
> How would it not be threadsafe? In the worst case, we store the (same)
> function pointer address in that variable twice (or, oh no!!!, even 3
> times). However, the value should never be invalid unless the compiler
> is on drugs and clears the variable before storing the actual address
> in it.
You never know what it might do :-).
But seriously, I don't see much of a point (unless with further changes),
a) I doubt the performance if getnameinfo matters in any way, at least on that scale.
b) The non-complex way to do it would only avoid the overhead if getnameinfo etc. are available.
However I don't really care either way.
More information about the ffmpeg-devel