mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
collector: disable re-entrancy during initialization
When creating a new collector, we need to prevent the following call to sysprof_malloc0() from re-entering us into the same position.
This commit is contained in:
committed by
Philip Withnall
parent
a9f136550b
commit
5d20c3f6cf
@ -410,6 +410,12 @@ sysprof_collector_get (void)
|
||||
{
|
||||
SysprofCollector *self, *old_collector;
|
||||
|
||||
/* First set the collector to invalid so anything recursive
|
||||
* here fails instead of becoming re-entrant.
|
||||
*/
|
||||
pthread_setspecific (collector_key, COLLECTOR_INVALID);
|
||||
|
||||
/* Now we can malloc without ending up here again */
|
||||
self = sysprof_malloc0 (sizeof (SysprofCollector));
|
||||
if (self == NULL)
|
||||
return COLLECTOR_INVALID;
|
||||
|
||||
Reference in New Issue
Block a user