I was troubleshooting a problem earlier today and noticed that:
a) Synchronous calls in Protocols.HTTP.Query don’t populate the DNS cache and b) The doesn’t seem to be any TTL for entries in either the cache Query or the one in Session.
I didn’t remedy a) because I think doing so without having a way to expire records would cause undesirable behavior for hostnames (especially) with multiple addresses. Any cache probably ought to at least respect the TTL on the DNS record as an upper bound. Does anyone have any thoughts about this?
Bill
On Sat, Jun 3, 2017 at 9:31 AM, H. William Welliver III william@welliver.org wrote:
I was troubleshooting a problem earlier today and noticed that:
a) Synchronous calls in Protocols.HTTP.Query don’t populate the DNS cache and b) The doesn’t seem to be any TTL for entries in either the cache Query or the one in Session.
I didn’t remedy a) because I think doing so without having a way to expire records would cause undesirable behavior for hostnames (especially) with multiple addresses. Any cache probably ought to at least respect the TTL on the DNS record as an upper bound. Does anyone have any thoughts about this?
For hostnames with multiple addresses, there's currently no clean way to establish a connection. For example, Protocols.WebSocket.Connection()->connect("ws://gideon.rosuav.com:8000/ws") will often fail because that hostname has both IPv6 and IPv4 addresses, and it'll often fail on the IPv6 without falling back on IPv4. So what I'd like to see is something that constructs and returns a socket connection.
Prior art: https://docs.python.org/3/library/socket.html#socket.create_connection https://github.com/Rosuav/Gypsum/blob/master/globals.pike#L1345
The latter is currently built to be entirely asynchronous, and as such bypasses gethostbyname and does direct DNS queries. That's unideal (it ignores /etc/nsswitch and /etc/hosts), but so is stalling out waiting for DNS. (Plus, I'm not sure gethostbyname will return mixed v4/v6 addresses anyway. Will it?)
My preferred solution, then, is to create a stdlib function for establishing a connection (eg Stdio.create_socket()), and then have that use a DNS cache. Then using that function for stuff like Protocols.HTTP.Query will automatically get all the benefit.
ChrisA
pike-devel@lists.lysator.liu.se