mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-16 14:18:27 +00:00
Linux: Add 'Platform_thread' destructor
This commit is contained in:
@ -68,7 +68,14 @@ Genode::Ep_socket_descriptor_registry *Genode::ep_sd_registry()
|
||||
*/
|
||||
static int lookup_tid_by_client_socket(int sd)
|
||||
{
|
||||
sockaddr_un name;
|
||||
/*
|
||||
* Synchronize calls so that the large 'sockaddr_un' can be allocated
|
||||
* in the BSS rather than the stack.
|
||||
*/
|
||||
Lock lock;
|
||||
Lock::Guard guard(lock);
|
||||
|
||||
static sockaddr_un name;
|
||||
socklen_t name_len = sizeof(name);
|
||||
int ret = lx_getpeername(sd, (sockaddr *)&name, &name_len);
|
||||
if (ret < 0)
|
||||
|
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user