mirror of
https://review.haiku-os.org/haiku
synced 2025-02-23 14:08:15 +01:00
although it put the freed space in the free list. Alternating invocations of alloc_...() and free_...() would thus increase the header space unboundedly. * Unified the way a data_header and data_node access the header space. Originally data_header::data_space and data_node::header_space had to be kept in sync, which some functions failed to do. Introduced a header_space structure, which is located in data_header and referenced by data_node, so that accessing it either way does always keep both structures in sync. * Removed the special handling for the data node created with a buffer. Since remove_{header,trailer}() and trim() could remove it without knowing, the last reference to the first data header would be freed prematurely, causing operations on freed memory, and in the end a second free which screwed the object cache's free list. This crashed Haiku e.g. when running OpenSSH's "forwarding" test. Now the first created node is just a node like any other. It's allocated in the data header, too. * Changed the mechanism how data nodes are allocated. Now they will always be allocated on a header associated with the buffer for which they are created. This fixes a race condition when freeing them. They would otherwise modify the free list of a header which might be accessed by another thread at the same time (added a TODO explaining how the old code could possibly be fixed). Also squashed several TODOs related to running out of header space when allocating a node. If the buffer runs out of header space, it will simply allocate a new header, now. * Dealt with some TODOs regarding reverting the buffer to its previous state when running out of memory after allocating a few nodes. * Added several TODOs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25256 a95241bf-73f2-0310-859d-f6bbb57e9c96