Linux: Add 'Platform_thread' destructor

This commit is contained in:
Norman Feske
2012-11-05 17:23:50 +01:00
parent d64dea51c0
commit 90395e9428
4 changed files with 40 additions and 1 deletions

View File

@ -60,6 +60,8 @@ class Genode::Socket_descriptor_registry
Entry(int fd, int global_id) : fd(fd), global_id(global_id) { }
bool is_free() const { return fd == -1; }
void mark_as_free() { fd = -1; }
};
Entry _entries[MAX_FDS];
@ -75,6 +77,15 @@ class Genode::Socket_descriptor_registry
throw Limit_reached();
}
Entry &_find_entry_by_fd(int fd)
{
for (unsigned i = 0; i < MAX_FDS; i++)
if (_entries[i].fd == fd)
return _entries[i];
throw Limit_reached();
}
bool _is_registered(int global_id) const
{
for (unsigned i = 0; i < MAX_FDS; i++)
@ -112,6 +123,13 @@ class Genode::Socket_descriptor_registry
entry = Entry(sd, global_id);
}
void disassociate(int sd)
{
Genode::Lock::Guard guard(_lock);
_find_entry_by_fd(sd).mark_as_free();
}
/**
* Lookup file descriptor that belongs to specified global ID
*