diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-03-27 02:26:22 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-03-27 02:26:22 +0000 |
commit | 7bdc8eacf14ff0bca9f99ae14302fd94aa7c4ce1 (patch) | |
tree | f4f285c0b1b3f0e52d5f576c3c8512b633596df3 /packet.c | |
parent | d56c57d9a35f178e4121a45ddfaf16cd162671ab (diff) | |
download | gpsd-7bdc8eacf14ff0bca9f99ae14302fd94aa7c4ce1.tar.gz |
Significant simplification of the packet-getter interface.
packet_get() now always returns nonzero when it could either read
fresh data or assemble a packet from data already read and buffered --
no more returning 0 when it has assembled a packet from buffered data
but can't read any new data. I suspect this may have been causing
subtle bugs.
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -1425,11 +1425,16 @@ ssize_t packet_get(int fd, struct gps_packet_t *lexer) /* Otherwise, consume from the packet input buffer */ packet_parse(lexer); - /* - * recvd can still be 0 or -1 at this point even if buffer data - * was consumed. It could be -1 on a transient read error. - */ - return recvd; + /* If we gathered a packet, return its length */ + if (lexer->outbuflen > 0) + return lexer->outbuflen; + else + /* + * Otherwise recvd is the size of whatever packet fragment we got. + * It can still be 0 or -1 at this point even if buffer data + * was consumed. + */ + return recvd; } void packet_reset(struct gps_packet_t *lexer) |