diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-04-07 00:27:29 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-04-07 00:27:29 -0400 |
commit | a0f13cb50324d587303402a6ac2713258f056177 (patch) | |
tree | ec27ab5ff53282c087db339d019d5926309c0161 /gpsd.c | |
parent | d2f16c844c15a6a0d0ea148f9e4c4a0962925cdf (diff) | |
download | gpsd-a0f13cb50324d587303402a6ac2713258f056177.tar.gz |
Always change the polling set in deactivate_device().
That is, as opposed to happening to do it near the call sites. This
is nearly a pure refactoring step, but caaught one potential bug in
the control-port handler.
All regression tests pass.
Diffstat (limited to 'gpsd.c')
-rw-r--r-- | gpsd.c | 12 |
1 files changed, 2 insertions, 10 deletions
@@ -616,6 +616,8 @@ static void deactivate_device(struct gps_device_t *device) "{\"class\":\"DEVICE\",\"path\":\"%s\",\"activated\":0}\r\n", device->gpsdata.dev.path); if (device->gpsdata.gps_fd != -1) { + FD_CLR(device->gpsdata.gps_fd, &all_fds); + adjust_max_fd(device->gpsdata.gps_fd, false); gpsd_deactivate(device); device->gpsdata.gps_fd = -1; /* device is already disconnected */ } @@ -761,10 +763,6 @@ static void handle_control(int sfd, char *buf) p = snarfline(buf+1, &stash); gpsd_report(LOG_INF, "<= control(%d): removing %s\n", sfd, stash); if ((devp = find_device(stash))) { - if (devp->gpsdata.gps_fd > 0) { - FD_CLR(devp->gpsdata.gps_fd, &all_fds); - adjust_max_fd(devp->gpsdata.gps_fd, false); - } deactivate_device(devp); free_device(devp); ignore_return(write(sfd, "OK\n", 3)); @@ -1602,12 +1600,8 @@ int main(int argc, char *argv[]) if (changed == ERROR_SET) { gpsd_report(LOG_WARN, "packet sniffer failed to sync up\n"); - FD_CLR(device->gpsdata.gps_fd, &all_fds); - adjust_max_fd(device->gpsdata.gps_fd, false); deactivate_device(device); } else if ((changed & ONLINE_SET) == 0) { - FD_CLR(device->gpsdata.gps_fd, &all_fds); - adjust_max_fd(device->gpsdata.gps_fd, false); deactivate_device(device); } else { @@ -1820,8 +1814,6 @@ int main(int argc, char *argv[]) } else if (timestamp() - device->releasetime > RELEASE_TIMEOUT) { gpsd_report(LOG_PROG, "device %d closed\n", (int)(device-devices)); gpsd_report(LOG_RAW, "unflagging descriptor %d\n", device->gpsdata.gps_fd); - FD_CLR(device->gpsdata.gps_fd, &all_fds); - adjust_max_fd(device->gpsdata.gps_fd, false); deactivate_device(device); } } |