diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-12-16 17:57:46 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-12-16 17:57:46 -0500 |
commit | 4a8ba33a11077c241c60cf888f1c5ddb6bbb5b4b (patch) | |
tree | 0a3ee4eb9604930556a29c4f5a46b75daab994f7 | |
parent | fd203176f17c88b334008ce752009213f1c127e3 (diff) | |
download | gpsd-4a8ba33a11077c241c60cf888f1c5ddb6bbb5b4b.tar.gz |
Refactor to turf all uses of gpsd_report() out of netlib.c
A recent bug report makes it clear that all such uses have to be removed from
the client libraries. Otherwise a GUI client might dummp log messages uselessly
in the X session error log. This is a start.
-rw-r--r-- | libgps_core.c | 4 | ||||
-rw-r--r-- | libgpsd_core.c | 6 | ||||
-rw-r--r-- | net_ntrip.c | 13 | ||||
-rw-r--r-- | netlib.c | 3 |
4 files changed, 17 insertions, 9 deletions
diff --git a/libgps_core.c b/libgps_core.c index ad3dd8e4..2ca14364 100644 --- a/libgps_core.c +++ b/libgps_core.c @@ -96,8 +96,12 @@ int gps_open(/*@null@*/const char *host, /*@null@*/const char *port, if ((gpsdata->gps_fd = netlib_connectsock(AF_UNSPEC, host, port, "tcp")) < 0) { errno = gpsdata->gps_fd; + gpsd_report(LOG_SPIN, "netlib_connectsock() returns error %d\n", errno); return -1; } + else + gpsd_report(LOG_SPIN, "netlib_connectsock() returns socket on fd %d\n", + gpsdata->gps_fd); #else QTcpSocket *sock = new QTcpSocket(); gpsdata->gps_fd = sock; diff --git a/libgpsd_core.c b/libgpsd_core.c index 304799ed..1d7a9f06 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -656,7 +656,8 @@ int gpsd_activate(struct gps_device_t *session) gpsd_report(LOG_ERROR, "TCP device open error %s.\n", netlib_errstr(dsock)); return -1; - } + } else + gpsd_report(LOG_SPIN, "TCP device opened on fd %d\n", dsock); session->gpsdata.gps_fd = dsock; session->sourcetype = source_tcp; } else if (strncmp(session->gpsdata.dev.path, "udp://", 6) == 0) { @@ -676,7 +677,8 @@ int gpsd_activate(struct gps_device_t *session) gpsd_report(LOG_ERROR, "UDP device open error %s.\n", netlib_errstr(dsock)); return -1; - } + } else + gpsd_report(LOG_SPIN, "UDP device opened on fd %d\n", dsock); session->gpsdata.gps_fd = dsock; session->sourcetype = source_udp; } diff --git a/net_ntrip.c b/net_ntrip.c index 4e411f2f..ac6c53b0 100644 --- a/net_ntrip.c +++ b/net_ntrip.c @@ -305,15 +305,16 @@ static int ntrip_stream_probe(const char *caster, char buf[BUFSIZ]; if ((dsock = netlib_connectsock(AF_UNSPEC, caster, port, "tcp")) == -1) { - printf("ntrip stream connect error %d\n", dsock); + gpsd_report(LOG_ERROR, "ntrip stream connect error %d\n", dsock); return -1; - } + } else + gpsd_report(LOG_SPIN, "ntrip stream connectrd on fd %d\n", dsock); (void)snprintf(buf, sizeof(buf), "GET / HTTP/1.1\r\n" "User-Agent: NTRIP gpsd/%s\r\n" "Connection: close\r\n" "\r\n", VERSION); if (write(dsock, buf, strlen(buf)) != (ssize_t) strlen(buf)) { - printf("ntrip stream write error %d\n", dsock); + gpsd_report(LOG_ERROR, "ntrip stream write error %d\n", dsock); return -1; } ret = @@ -364,8 +365,12 @@ static int ntrip_stream_open(const char *caster, const char *port, return -1; } if ((context->dsock = - netlib_connectsock(AF_UNSPEC, caster, port, "tcp")) < 0) + netlib_connectsock(AF_UNSPEC, caster, port, "tcp")) < 0) { + gpsd_report(LOG_ERROR,"netlib_connectsock() returns error %d\n", errno); return -1; + } else + gpsd_report(LOG_SPIN, "netlib_connectsock() returns socket on fd %d\n", + context->dsock); (void)snprintf(buf, sizeof(buf), "GET /%s HTTP/1.1\r\n" @@ -94,7 +94,6 @@ socket_t netlib_connectsock(int af, const char *host, const char *service, } if (s > 0) { - gpsd_report(LOG_SPIN, "close(%d) in netlib_connectsock()\n", s); (void)close(s); } } @@ -121,8 +120,6 @@ socket_t netlib_connectsock(int af, const char *host, const char *service, /* set socket to noblocking */ (void)fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK); - gpsd_report(LOG_SPIN, "netlib_connectsock() returns socket on fd %d\n", - s); return s; /*@ +type +mustfreefresh @*/ } |