From ac5ab2343e93ac141460ab23954ea53ba66517fb Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 16 Mar 2015 10:20:18 -0400 Subject: Attempted fix for a close/reopen bug involvinf NMEA2000. This was reported on gosd-users by Vignesh Krishnan : > 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. --- driver_nmea2000.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'driver_nmea2000.c') 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;l1driver.nmea2000.unit_valid = 0; + session->driver.nmea2000.unit = 0; + session->driver.nmea2000.can_net = 0; + nmea2000_units[l1][l2] = NULL; + } + } + } + } } } -- cgit v1.2.1