summaryrefslogtreecommitdiff
path: root/gps
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2016-02-28 14:24:52 -0800
committerFred Wright <fw@fwright.net>2016-02-29 13:49:09 -0800
commit722e44036fbc520399c8dab1d524489b3b9cabee (patch)
tree100a54d9abc3bde94aa0a8067cc852794c3a5565 /gps
parent717d8d0651376e77664017f6a57f3fbab782ec8a (diff)
downloadgpsd-722e44036fbc520399c8dab1d524489b3b9cabee.tar.gz
Eliminates spurious gpsd errors with gpsfake in TCP mode.
Depending on timing, in TCP mode, gpsd may try to reconnect to fake.py between the time that the logfile is complete and the time that the remove_device is issued. With no listener, this results in a set of three error messages from gpsd. They don't affect the test outcome, since they only go to stderr and the "real" output is complete, but they're annoying to the user. The likelihood of this happening increases with longer logfiles and with larger WRITE_PAD values. With a 30ms WRITE_PAD (the default on OSX), most logfiles exhibit this on all platforms, though it's not seen on Linux with the default zero WRITE_PAD. The fix is simply to avoid closing the listener after accepting the incoming connection. It's not necessary to explicitly service the listener further, since the OS listen queue is sufficient to accept the additional connection. Closing the listener at drain time is almost acceptable, but still occasionally fails due to the fact that drain() is (necessarily) called before remove_device(). Not explicitly closing it at all is acceptable, since Python closes it as part of the object cleanup. TESTED: Ran regress-driver in TCP mode with a 30ms WRITE_PAD on all logfiles on three versions of OSX, as well as Linux, FreeBSD, and OpenBSD, both with and without the fix. Observed spurious errors in all cases without the fix, and no cases with the fix. Also verified that no dangling sockets were left at the end of the runs.
Diffstat (limited to 'gps')
-rw-r--r--gps/fake.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/gps/fake.py b/gps/fake.py
index 104ab763..5ba980bc 100644
--- a/gps/fake.py
+++ b/gps/fake.py
@@ -365,7 +365,12 @@ class FakeTCP(FakeGPS):
if s == self.dispatcher: # Connection request
client_socket, _address = s.accept()
self.readables = [client_socket]
- self.dispatcher.close()
+ # Depending on timing, gpsd may try to reconnect between the
+ # end of the log data and the remove_device. With no listener,
+ # this results in spurious error messages. Keeping the listener
+ # around avoids this. It will eventually be closed by the
+ # Python object cleanup.
+ ## self.dispatcher.close()
else: # Incoming data
data = s.recv(1024)
if not data: