summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-05-31 10:37:20 -0400
committerEric S. Raymond <esr@thyrsus.com>2015-05-31 10:37:20 -0400
commit967c40b2f75321ca93408fde1f577e69f501cfc7 (patch)
treed1fcad6a8f8764a7117a9e1ecac2e57faaf43cd3 /gpsd.c
parent557f30295be92d75fafff883a212933d74da46e5 (diff)
downloadgpsd-967c40b2f75321ca93408fde1f577e69f501cfc7.tar.gz
Free a GPS if it fails to activate on awakening. Fixes crash-exit bug.
Modified version of a patch by "Brian T (gmail)" <btuchten@gmail.com>. He reports: Using GPSd 3.14, if it is told to read TTY device, and then a USB GPS device is added, and then the USB device is removed, GPSd exits. I had seen others talk about this but never found an answer. The work around I found was the attached patch. I had it as a new command line option, but removed that part after reading the hacking guidelines. Tested this way: Device on /dev/ttyS4 gpsdctl add /dev/ttyUSB1 GPSd can be seen polling both devices Physically remove USB device GPSd continues processing ttyS4, removes ttyUSB1 Device on /dev/ttyS4 Add device on /dev/ttyUSB1 gpsdctl remove /dev/ttyS4 Physically remove USB device GPSd waits on select() gpsdctl add /dev/ttyS4 GPSd starts processing ttyS4, removes ttyUSB1 Insert USB device gpsdctl add /dev/ttyUSB1 GPSd polls both devices I did notice that if USB1 is the last device left in the list, and the USB is pulled, GPSd does not syslog the message it was removed until a new device (like ttyS4) is added back in. Then the syslog message shows up. The reason for this is some embedded cellular modules have embedded GPS. Sometimes the modules reset without notice, so the device is gone from the USB stack before a udev script can catch it and send a "gpsdctl remove xxxx", and then GPSd exits.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gpsd.c b/gpsd.c
index 2bce7934..1c4d47de 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -947,6 +947,10 @@ static bool awaken(struct gps_device_t *device)
gpsd_log(&context.errout, LOG_ERROR,
"%s: device activation failed.\n",
device->gpsdata.dev.path);
+ gpsd_log(&context.errout, LOG_ERROR,
+ "%s: activation failed, freeing device\n",
+ device->gpsdata.dev.path);
+ free_device(device);
return false;
} else {
gpsd_log(&context.errout, LOG_RAW,