diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-06-16 11:23:37 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-06-16 11:23:37 -0400 |
commit | 730b2feea3b2da3d046b25b119375682dea5e179 (patch) | |
tree | 483b66abb77bd63dc3773b07371041175c2a3558 /libgpsd_core.c | |
parent | 43ea138f243d0cc3b64fe81dc96298f64e1be4c5 (diff) | |
download | gpsd-730b2feea3b2da3d046b25b119375682dea5e179.tar.gz |
Refactor to avoid duplicating work on zero-length packets.
All regression tests pass.
Diffstat (limited to 'libgpsd_core.c')
-rw-r--r-- | libgpsd_core.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/libgpsd_core.c b/libgpsd_core.c index e829634b..4dbfb1a4 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -826,32 +826,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) session->gpsdata.dev.path, session->device_type->type_name); } else { - const struct gps_type_t **dp; - newlen = generic_get(session); - gpsd_report(LOG_RAW, - "packet sniff on %s finds type %d\n", - session->gpsdata.dev.path, session->packet.type); - if (session->packet.type == COMMENT_PACKET) { - gpsd_report (LOG_PROG, "comment, sync lock deferred\n"); -#ifdef PASSTHROUGH_ENABLE - } else if (session->packet.type == JSON_PACKET) { - gpsd_report (LOG_PROG, "JSON, sync lock deferred\n"); -#endif /* PASSTHROUGH_ENABLE */ - } else if (session->packet.type > COMMENT_PACKET) { - first_sync = (session->device_type == NULL); - for (dp = gpsd_drivers; *dp; dp++) - if (session->packet.type == (*dp)->packet_type) { - (void)gpsd_switch_driver(session, (*dp)->type_name); - break; - } - } else if (session->getcount++>1 && !gpsd_next_hunt_setting(session)) { - gpsd_run_device_hook(session->gpsdata.dev.path, "DEACTIVATE"); - gpsd_report(LOG_INF, "hunt on %s failed (%lf sec since data)\n", - session->gpsdata.dev.path, - timestamp() - session->gpsdata.online); - return ERROR_SET; - } } /* update the scoreboard structure from the GPS */ @@ -875,7 +850,32 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) session->gpsdata.online = (timestamp_t)0; } return NODATA_IS; - } else if (session->packet.outbuflen == 0) { /* got new data, but no packet */ + } else /* (newlen > 0) */ { + const struct gps_type_t **dp; + + gpsd_report(LOG_RAW, + "packet sniff on %s finds type %d\n", + session->gpsdata.dev.path, session->packet.type); + if (session->packet.type == COMMENT_PACKET) { + gpsd_report (LOG_PROG, "comment, sync lock deferred\n"); + } else if (session->packet.type > COMMENT_PACKET) { + first_sync = (session->device_type == NULL); + for (dp = gpsd_drivers; *dp; dp++) + if (session->packet.type == (*dp)->packet_type) { + (void)gpsd_switch_driver(session, (*dp)->type_name); + break; + } + /* FALL THROUGH */ + } else if (session->getcount++>1 && !gpsd_next_hunt_setting(session)) { + gpsd_run_device_hook(session->gpsdata.dev.path, "DEACTIVATE"); + gpsd_report(LOG_INF, "hunt on %s failed (%lf sec since data)\n", + session->gpsdata.dev.path, + timestamp() - session->gpsdata.online); + return ERROR_SET; + } + } + + if (session->packet.outbuflen == 0) { /* got new data, but no packet */ gpsd_report(LOG_RAW + 3, "New data on %s, not yet a packet\n", session->gpsdata.dev.path); return ONLINE_SET; |