diff options
author | Miles Bader <miles@gnu.org> | 1996-01-12 17:29:39 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-01-12 17:29:39 +0000 |
commit | a22738e903562f8df335cca68c3d76770cd8b94a (patch) | |
tree | 918cfc301cceb15d464ecb0c9d131a0c6c3afdcb | |
parent | 0bfab92b5b72a4381afbf47b015c2068e5b94918 (diff) |
(pq_queue): Initialize the ports_alloced field.
(packet_read): When a page-aligned read consumes the whole buffer, but there's
a non-page-multiple amount available, don't let buf_len go negative.
-rw-r--r-- | libpipe/pq.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libpipe/pq.c b/libpipe/pq.c index 31937573..8177dfe2 100644 --- a/libpipe/pq.c +++ b/libpipe/pq.c @@ -126,7 +126,7 @@ pq_queue (struct pq *pq, unsigned type, void *source) packet->buf = 0; packet->buf_len = 0; packet->ports = 0; - packet->num_ports = 0; + packet->num_ports = packet->ports_alloced = 0; packet->buf_start = packet->buf_end = packet->buf; } else @@ -388,13 +388,17 @@ packet_read (struct packet *packet, if (start > end) /* Make sure BUF_START is never beyond BUF_END (page-aligning the new BUF_START may have move it past). */ - packet->buf_end = start; + { + packet->buf_end = start; + packet->buf_len = 0; /* Pin at 0, despite moving past the end. */ + } + else + /* Adjust BUF_LEN to reflect what the read has consumed. */ + packet->buf_len -= start - buf; - /* We've actually consumed the memory at the start of BUF, so - adjust it and BUF_LEN to reflect this. */ + /* We've actually consumed the memory at the start of BUF. */ packet->buf = start; packet->buf_start = start; - packet->buf_len -= start - buf; } else /* Just copy the data the old fashioned way.... */ |