gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH] Eliminates spurious gpsd errors with gpsfake in TCP m


From: Fred Wright
Subject: [gpsd-dev] [PATCH] Eliminates spurious gpsd errors with gpsfake in TCP mode.
Date: Sun, 28 Feb 2016 15:44:47 -0800

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.
---
 gps/fake.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gps/fake.py b/gps/fake.py
index 476f52e..4da48e7 100644
--- a/gps/fake.py
+++ b/gps/fake.py
@@ -352,7 +352,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:
-- 
2.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]