summaryrefslogtreecommitdiff
path: root/gpsctl.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-01-02 17:29:09 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-01-02 17:29:09 -0500
commitccaf8549c8b4484f67c74e2f54af0511f67855c5 (patch)
tree9241f4106ae5a33a29bf31bd47b8db7046968a87 /gpsctl.c
parent48219acd5c63c674825c7920463b5999eaa4e3d2 (diff)
downloadgpsd-ccaf8549c8b4484f67c74e2f54af0511f67855c5.tar.gz
Fix the start-of-session race condition.
Diffstat (limited to 'gpsctl.c')
-rw-r--r--gpsctl.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/gpsctl.c b/gpsctl.c
index cc3060aa..2db6f6a5 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -312,19 +312,13 @@ int main(int argc, char **argv)
if (!lowlevel) {
int i;
- /* OK, there's a daemon instance running. Do things the easy way */
- (void)gps_read(&gpsdata);
- if ((gpsdata.set & VERSION_SET) != 0) {
- gpsd_report(LOG_ERROR, "no VERSION response received; update your gpsd.\n");
- (void)gps_close(&gpsdata);
- exit(1);
- }
+
+ /* what devices have we available? */
if (!gps_query(&gpsdata, DEVICELIST_SET, (int)timeout, "?DEVICES;\n")) {
gpsd_report(LOG_ERROR, "no DEVICES response received.\n");
(void)gps_close(&gpsdata);
exit(1);
}
-
if (gpsdata.devices.ndevices == 0) {
gpsd_report(LOG_ERROR, "no devices connected.\n");
(void)gps_close(&gpsdata);
@@ -337,7 +331,7 @@ int main(int argc, char **argv)
}
gpsd_report(LOG_PROG,"%d device(s) found.\n",gpsdata.devices.ndevices);
- /* query the devicelist return */
+ /* try to mine the devicelist return for the data we want */
if (gpsdata.devices.ndevices == 1 && device == NULL) {
device = gpsdata.dev.path;
i = 0;
@@ -347,7 +341,7 @@ int main(int argc, char **argv)
if (strcmp(device, gpsdata.devices.list[i].path) == 0) {
goto devicelist_entry_matches;
}
- gpsd_report(LOG_ERROR, "specified device not found.\n");
+ gpsd_report(LOG_ERROR, "specified device not found in device list.\n");
(void)gps_close(&gpsdata);
exit(1);
devicelist_entry_matches:;