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:
Christian Hergert
2020-07-02 15:19:16 -07:00
committed by Philip Withnall
parent a9f136550b
commit 5d20c3f6cf

View File

@ -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;