* We need to acquire references to the interface_address when copying/cloning
the buffer, and we also need to release it when freeing it. * Adapted patch by Atis: append_cloned_data() now preserves the stored header; this is kind of bad, because it will not notice if the original header is removed, but this could probably just be documented this way. * Also print the reference count of the interface addresses. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37993 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -325,6 +325,8 @@ InterfaceAddress::Dump(size_t index, bool hideInterface)
|
|||||||
} else
|
} else
|
||||||
strcpy(buffer, "-");
|
strcpy(buffer, "-");
|
||||||
kprintf(" destination: %s\n", buffer);
|
kprintf(" destination: %s\n", buffer);
|
||||||
|
|
||||||
|
kprintf(" ref count: %" B_PRId32 "\n", CountReferences());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1075,6 +1075,9 @@ copy_metadata(net_buffer* destination, const net_buffer* source)
|
|||||||
|
|
||||||
destination->flags = source->flags;
|
destination->flags = source->flags;
|
||||||
destination->interface_address = source->interface_address;
|
destination->interface_address = source->interface_address;
|
||||||
|
if (destination->interface_address != NULL)
|
||||||
|
((InterfaceAddress*)destination->interface_address)->AcquireReference();
|
||||||
|
|
||||||
destination->offset = source->offset;
|
destination->offset = source->offset;
|
||||||
destination->protocol = source->protocol;
|
destination->protocol = source->protocol;
|
||||||
destination->type = source->type;
|
destination->type = source->type;
|
||||||
@@ -1156,6 +1159,9 @@ free_buffer(net_buffer* _buffer)
|
|||||||
delete_ancillary_data_container(buffer->ancillary_data);
|
delete_ancillary_data_container(buffer->ancillary_data);
|
||||||
|
|
||||||
release_data_header(buffer->allocation_header);
|
release_data_header(buffer->allocation_header);
|
||||||
|
|
||||||
|
if (buffer->interface_address != NULL)
|
||||||
|
((InterfaceAddress*)buffer->interface_address)->ReleaseReference();
|
||||||
|
|
||||||
free_net_buffer(buffer);
|
free_net_buffer(buffer);
|
||||||
}
|
}
|
||||||
@@ -1972,7 +1978,12 @@ append_cloned_data(net_buffer* _buffer, net_buffer* _source, uint32 offset,
|
|||||||
clone->offset = buffer->size;
|
clone->offset = buffer->size;
|
||||||
clone->start = node->start + offset;
|
clone->start = node->start + offset;
|
||||||
clone->used = min_c(bytes, node->used - offset);
|
clone->used = min_c(bytes, node->used - offset);
|
||||||
clone->flags |= DATA_NODE_READ_ONLY;
|
if (list_is_empty(&buffer->buffers)) {
|
||||||
|
// take over stored offset
|
||||||
|
buffer->stored_header_length = source->stored_header_length;
|
||||||
|
clone->flags = node->flags | DATA_NODE_READ_ONLY;
|
||||||
|
} else
|
||||||
|
clone->flags = DATA_NODE_READ_ONLY;
|
||||||
|
|
||||||
list_add_item(&buffer->buffers, clone);
|
list_add_item(&buffer->buffers, clone);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user