ocean icon indicating copy to clipboard operation
ocean copied to clipboard

There are two contradictory declarations of addrinfo

Open don-clugston-sociomantic opened this issue 6 years ago • 5 comments

ocean.sys.socket.AddrInfo contains a struct addrinfo which is described as "Address information struct as returned by getaddrinfo().", and it contains an extern(C) declaration of getaddrinfo.

However, core.sys.posix.netdb also contains a struct addrinfo, and a declaration of getaddrinfo.

But, ocean.sys.socket.AddrInfo imports the enum values which getaddrinfo needs, from core.sys.posix.netinet.in_. So this module is not even consistent about whether it is using the druntime declarations, or not.

In D2, these structs are not identical. Mixing the two declararations works in D1, but it D2 it generates really weird error messages. Probably the socket.AddrInfo declaration of addrinfo should be replaced with a public import of the druntime declaration.

@nemanja-boric-sociomantic @david-eckardt-sociomantic do you know anything about it?

mihails-strasuns avatar Aug 30 '18 13:08 mihails-strasuns

I'll check on Monday. I think the work there predates the time when we wanted to be consistent with D2 runtime, so I think it's just a bug (what Don is saying sounds feasible). I don't think anybody is importing this from the outside (I think it's only used internally) so we should be good to patch this in a point release.

Nemanja


From: Mihails Strasuns [email protected] Sent: 30 August 2018 15:25:38 To: sociomantic-tsunami/ocean Cc: Nemanja Boric; Mention Subject: Re: [sociomantic-tsunami/ocean] There are two contradictory declarations of addrinfo (#624)

@nemanja-boric-sociomantichttps://github.com/nemanja-boric-sociomantic @david-eckardt-sociomantichttps://github.com/david-eckardt-sociomantic do you know anything about it?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/sociomantic-tsunami/ocean/issues/624#issuecomment-417318256, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHF88KUAB2TN9OV73Ha14lIQY5QA_LOkks5uV-fSgaJpZM4WRA2m.

This looks like my handwriting. I don't remember why I wrote it so I guess addrinfo and getaddrinfo were somehow missing in the runtime at this time.

So, the problem here is that ocean definition does not exactly match druntime one - it has bunch of helper methods and defines error code and flag enums as named types, all that public and part of addrinfo struct. So switching to druntime version is actually a breaking change.

mihails-strasuns avatar Sep 23 '18 14:09 mihails-strasuns

tbh to me easiest fix would to deprecate whole module and provide ocean.sys.socket.AddrInfo2 instead which uses druntime version (and renaming back in next major).

mihails-strasuns avatar Sep 23 '18 14:09 mihails-strasuns