summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpipe/ChangeLog10
-rw-r--r--libpipe/pq.c13
2 files changed, 18 insertions, 5 deletions
diff --git a/libpipe/ChangeLog b/libpipe/ChangeLog
index e0dc3ea1..41074717 100644
--- a/libpipe/ChangeLog
+++ b/libpipe/ChangeLog
@@ -1,3 +1,13 @@
+2002-04-22 Marcus Brinkmann <marcus@gnu.org>
+
+ * pq.c (packet_set_ports): Correctly replace old ports buffer with
+ new one. Take size of mach_port_t rather than pointer to it.
+ (packet_read_ports): Take size of mach_port_t rather than pointer
+ to it.
+ (pq_queue): Update PACKET->num_ports, PACKET->buf_start and
+ PACKET->buf_end for reused packets as well.
+ Submitted by Ognyan Kulev <ogi@fmi.uni-sofia.bg>.
+
1999-07-10 Roland McGrath <roland@baalperazim.frob.com>
* pq.c: Add #include <sys/mman.h> for munmap decl.
diff --git a/libpipe/pq.c b/libpipe/pq.c
index 07196000..9267a3cd 100644
--- a/libpipe/pq.c
+++ b/libpipe/pq.c
@@ -127,13 +127,15 @@ pq_queue (struct pq *pq, unsigned type, void *source)
packet->buf = 0;
packet->buf_len = 0;
packet->ports = 0;
- packet->num_ports = packet->ports_alloced = 0;
- packet->buf_start = packet->buf_end = packet->buf;
+ packet->ports_alloced = 0;
packet->buf_vm_alloced = 0;
}
else
pq->free = packet->next;
+ packet->num_ports = 0;
+ packet->buf_start = packet->buf_end = packet->buf;
+
packet->type = type;
packet->source = source;
packet->next = 0;
@@ -295,13 +297,14 @@ packet_set_ports (struct packet *packet,
packet_dealloc_ports (packet);
if (num_ports > packet->ports_alloced)
{
- mach_port_t *new_ports = malloc (sizeof (mach_port_t *) * num_ports);
+ mach_port_t *new_ports = malloc (sizeof (mach_port_t) * num_ports);
if (! new_ports)
return ENOMEM;
free (packet->ports);
+ packet->ports = new_ports;
packet->ports_alloced = num_ports;
}
- bcopy (ports, packet->ports, sizeof (mach_port_t *) * num_ports);
+ bcopy (ports, packet->ports, sizeof (mach_port_t) * num_ports);
packet->num_ports = num_ports;
return 0;
}
@@ -312,7 +315,7 @@ error_t
packet_read_ports (struct packet *packet,
mach_port_t **ports, size_t *num_ports)
{
- int length = packet->num_ports * sizeof (mach_port_t *);
+ int length = packet->num_ports * sizeof (mach_port_t);
if (*num_ports < packet->num_ports)
{
*ports = mmap (0, length, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);