summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-04-07 00:27:29 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-04-07 00:27:29 -0400
commita0f13cb50324d587303402a6ac2713258f056177 (patch)
treeec27ab5ff53282c087db339d019d5926309c0161 /gpsd.c
parentd2f16c844c15a6a0d0ea148f9e4c4a0962925cdf (diff)
downloadgpsd-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.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/gpsd.c b/gpsd.c
index ea38579a..9e7d305f 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -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);
}
}