mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
libc: never destruct the file-descriptor allocator
This patch prevents the destruction of the fd allocator when the program exists. Otherwise, the meta data for file descriptors that were not manually closed would vanish, which may cause problems in subsequent destructors.
This commit is contained in:
parent
8971bb25ce
commit
329ab80d1d
@ -13,6 +13,7 @@
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/construct_at.h>
|
||||
#include <base/env.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
@ -23,8 +24,14 @@ namespace Libc {
|
||||
|
||||
File_descriptor_allocator *file_descriptor_allocator()
|
||||
{
|
||||
static File_descriptor_allocator _file_descriptor_allocator;
|
||||
return &_file_descriptor_allocator;
|
||||
static bool constructed = 0;
|
||||
static char placeholder[sizeof(File_descriptor_allocator)];
|
||||
if (!constructed) {
|
||||
Genode::construct_at<File_descriptor_allocator>(placeholder);
|
||||
constructed = 1;
|
||||
}
|
||||
|
||||
return reinterpret_cast<File_descriptor_allocator *>(placeholder);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user