diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2015-03-16 10:20:18 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-03-16 20:08:57 -0400 |
commit | ac5ab2343e93ac141460ab23954ea53ba66517fb (patch) | |
tree | caa74f0bf39fd99ade39293a29ff4badda11d47b | |
parent | e8304a299aceb9b1cc7b6136d17f456872250ada (diff) | |
download | gpsd-ac5ab2343e93ac141460ab23954ea53ba66517fb.tar.gz |
Attempted fix for a close/reopen bug involvinf NMEA2000.
This was reported on gosd-users by Vignesh Krishnan <Krishnan_Vignesh@cat.com>:
> For the nmea2000 bug . I connect using gpsd control socket
>
> ./gpsd -n -F /tmp/control_sock
>
> Adding source is possible
> +nmea2000://can1
>
> Removing sourc is also possible with
> -nmea2000://can1
>
> Readding the source is not possible with
> +nmea2000://can1
>
> This is because the there is an array which stores the list of nmea
> devices. That is not cleared on removed. So adding the second time results
> in device exist error when actually device does not exist.
To address this, the driver close() method tries to zero the proper
array location.
All regression tests pass.
-rw-r--r-- | driver_nmea2000.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c index 309708b3..5b1e207d 100644 --- a/driver_nmea2000.c +++ b/driver_nmea2000.c @@ -1677,6 +1677,21 @@ void nmea2000_close(struct gps_device_t *session) session->gpsdata.gps_fd, session->gpsdata.dev.path); (void)close(session->gpsdata.gps_fd); INVALIDATE_SOCKET(session->gpsdata.gps_fd); + + if (session->driver.nmea2000.unit_valid != 0) { + unsigned int l1, l2; + + for (l1=0;l1<NMEA2000_NETS;l1++) { + for (l2=0;l2<NMEA2000_UNITS;l2++) { + if (session == nmea2000_units[l1][l2]) { + session->driver.nmea2000.unit_valid = 0; + session->driver.nmea2000.unit = 0; + session->driver.nmea2000.can_net = 0; + nmea2000_units[l1][l2] = NULL; + } + } + } + } } } |