mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +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 pid,
|
||||||
int tid)
|
int tid)
|
||||||
{
|
{
|
||||||
|
static GRWLock rwlock;
|
||||||
SysprofSymbol *ret;
|
SysprofSymbol *ret;
|
||||||
|
|
||||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), NULL);
|
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))))
|
if (!(ret = g_hash_table_lookup (self->tid_to_symbol, GINT_TO_POINTER (tid))))
|
||||||
{
|
{
|
||||||
char pidstr[32];
|
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_hash_table_insert (self->tid_to_symbol, GINT_TO_POINTER (tid), ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_rw_lock_writer_unlock (&rwlock);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user