- Use server.ping to ping (valid as of protocol version 1.2) rather
than server.version (deprecated as a ping)
- Ping every 5 mins rather than every 1 minute. By default servers
don't consider a connection stale until 10 minutes of inactivity.
- Remove unused last_request member of interface
Port of c3f26e59db
Previously network.py had its own idea of request IDs,
and each interface had its own which was sent on the wire.
The interface would jump through hoops to translate one
to the other.
This unifies them so that a message ID is passed when
queueing a request, in addition to the method and params.
network.py is now solely responsible for message ID management.
Apart from being simpler and clearer, this also should be faster
as there is much less data structure manipulation and rebuilding
happening.
Occurred when switching interfaces and there were unanswered
requests that need resending. This bug isn't new; it's been
there since at least 3rd June.
The existing pattern matching code:
val.find('*.') == 0 and name.find(val[1:]) + len(val[1:]) == len(name)
will return True in the following case:
val = '*.host.com'
name = 'blah.org'
since string.find() will return -1, len(val[1:]) == 9 and len(name) == 8.
This is a layering violation - the SocketPipe doesn't own
the socket and provides no other way to close the socket, leading
to unnecessary complexity like that in interface.py.
I looked at deamon.py and NetworkProxy - the two other users,
and they don't close the sockets explicitly, just let them be
garbage collected.
Set timeout and socket options on all simple sockets. At present
some code paths can miss it, such as when the SSL certificate is
CA-signed.
Add a missing check for failure.
This allows us to distinguish between connecting and connected
state in interface.py (used to be done in network.py but that
had other issues).
This means we don't switch to a connecting server, and get_interfaces()
does not report connecting ones.