mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 15:10:53 +00:00
libsysprof-capture: sleep and try again to get an event
Unless we've failed before, then just bail immediately so that applications which loose their controller keep running with minimal overhead.
This commit is contained in:
@ -69,6 +69,7 @@ struct _MappedRingBuffer
|
|||||||
void *map;
|
void *map;
|
||||||
size_t body_size;
|
size_t body_size;
|
||||||
size_t page_size;
|
size_t page_size;
|
||||||
|
unsigned has_failed : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline MappedRingHeader *
|
static inline MappedRingHeader *
|
||||||
@ -405,6 +406,8 @@ mapped_ring_buffer_allocate (MappedRingBuffer *self,
|
|||||||
assert (length < self->body_size);
|
assert (length < self->body_size);
|
||||||
assert ((length & 0x7) == 0);
|
assert ((length & 0x7) == 0);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < 1000; i++)
|
||||||
|
{
|
||||||
header = get_header (self);
|
header = get_header (self);
|
||||||
__atomic_load (&header->head, &headpos, __ATOMIC_SEQ_CST);
|
__atomic_load (&header->head, &headpos, __ATOMIC_SEQ_CST);
|
||||||
__atomic_load (&header->tail, &tailpos, __ATOMIC_SEQ_CST);
|
__atomic_load (&header->tail, &tailpos, __ATOMIC_SEQ_CST);
|
||||||
@ -427,6 +430,14 @@ mapped_ring_buffer_allocate (MappedRingBuffer *self,
|
|||||||
if (tailpos + length < headpos)
|
if (tailpos + length < headpos)
|
||||||
return get_body_at_pos (self, tailpos);
|
return get_body_at_pos (self, tailpos);
|
||||||
|
|
||||||
|
if (self->has_failed)
|
||||||
|
break;
|
||||||
|
|
||||||
|
usleep (1000); /* 1 msec */
|
||||||
|
}
|
||||||
|
|
||||||
|
self->has_failed = true;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user