mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-03-16 02:01:28 +00:00
libsysprof: synchronize access to tid symbols hashtable
This can get mutated after the document is loaded, so we need to synchronize access to it.
This commit is contained in:
@ -2102,10 +2102,19 @@ _sysprof_document_thread_symbol (SysprofDocument *self,
|
||||
int pid,
|
||||
int tid)
|
||||
{
|
||||
static GRWLock rwlock;
|
||||
SysprofSymbol *ret;
|
||||
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), NULL);
|
||||
|
||||
g_rw_lock_reader_lock (&rwlock);
|
||||
ret = g_hash_table_lookup (self->tid_to_symbol, GINT_TO_POINTER (tid));
|
||||
g_rw_lock_reader_unlock (&rwlock);
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
g_rw_lock_writer_lock (&rwlock);
|
||||
|
||||
if (!(ret = g_hash_table_lookup (self->tid_to_symbol, GINT_TO_POINTER (tid))))
|
||||
{
|
||||
char pidstr[32];
|
||||
@ -2127,6 +2136,9 @@ _sysprof_document_thread_symbol (SysprofDocument *self,
|
||||
g_hash_table_insert (self->tid_to_symbol, GINT_TO_POINTER (tid), ret);
|
||||
}
|
||||
|
||||
g_rw_lock_writer_unlock (&rwlock);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user