mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibCore: Don't leak EventLoopImplementationUnix's ThreadData
The ThreadData still has a lifetime a longer than the thread it was created for, but at least now it's not leaked at process exit.
This commit is contained in:
parent
d8103247d9
commit
a9fdd819c3
Notes:
sideshowbarker
2024-07-17 07:25:39 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/a9fdd819c3 Pull-request: https://github.com/SerenityOS/serenity/pull/24498
1 changed files with 2 additions and 3 deletions
|
@ -26,7 +26,7 @@ namespace {
|
|||
struct ThreadData;
|
||||
class TimeoutSet;
|
||||
|
||||
HashMap<pthread_t, ThreadData*> s_thread_data;
|
||||
HashMap<pthread_t, OwnPtr<ThreadData>> s_thread_data;
|
||||
static pthread_rwlock_t s_thread_data_lock_impl;
|
||||
static pthread_rwlock_t* s_thread_data_lock = nullptr;
|
||||
thread_local pthread_t s_thread_id;
|
||||
|
@ -228,11 +228,10 @@ struct ThreadData {
|
|||
ThreadData* data = nullptr;
|
||||
pthread_rwlock_rdlock(&*s_thread_data_lock);
|
||||
if (!s_thread_data.contains(s_thread_id)) {
|
||||
// FIXME: Don't leak this.
|
||||
data = new ThreadData;
|
||||
pthread_rwlock_unlock(&*s_thread_data_lock);
|
||||
pthread_rwlock_wrlock(&*s_thread_data_lock);
|
||||
s_thread_data.set(s_thread_id, data);
|
||||
s_thread_data.set(s_thread_id, adopt_own(*data));
|
||||
} else {
|
||||
data = s_thread_data.get(s_thread_id).value();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue