[vlc-devel] [PATCH] cache_block: account alloc size instead of payload
Francois Cartegnie
fcvlcdev at free.fr
Thu Jan 7 15:52:20 CET 2016
Current block_cache accounts only payload data which
results in storing far more data, than the expected
STREAM_CACHE_SIZE limit, when the access allocs
larger blocks than payload.
Ex: UDP 2^16 (max MTU), dtv (20 * 128).
reading re-streamed rtsp allocates more than 300MB
before reaching the payload cache size.
OOM'ing client only depends on bw if a server sends
zero or one byte sized payload UDP (limit becoming ~12*256GB)
refs #16315, #14458, #16270
---
modules/stream_filter/cache_block.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/modules/stream_filter/cache_block.c b/modules/stream_filter/cache_block.c
index dc31506..24f253a 100644
--- a/modules/stream_filter/cache_block.c
+++ b/modules/stream_filter/cache_block.c
@@ -72,7 +72,8 @@ struct stream_sys_t
uint64_t i_offset; /* Offset for data in p_current */
block_t *p_current; /* Current block */
- uint64_t i_size; /* Total amount of data in the list */
+ uint64_t i_alloc_size; /* Total amount of allocated data in the list */
+ uint64_t i_size; /* Total amount of payload data in the list */
block_t *p_first;
block_t **pp_last;
@@ -102,18 +103,19 @@ static int AStreamRefillBlock(stream_t *s)
stream_sys_t *sys = s->p_sys;
/* Release data */
- while (sys->i_size >= STREAM_CACHE_SIZE &&
+ while (sys->i_alloc_size >= STREAM_CACHE_SIZE &&
sys->p_first != sys->p_current)
{
block_t *b = sys->p_first;
sys->i_start += b->i_buffer;
sys->i_size -= b->i_buffer;
+ sys->i_alloc_size -= b->i_size;
sys->p_first = b->p_next;
block_Release(b);
}
- if (sys->i_size >= STREAM_CACHE_SIZE &&
+ if (sys->i_alloc_size >= STREAM_CACHE_SIZE &&
sys->p_current == sys->p_first &&
sys->p_current->p_next) /* At least 2 packets */
{
@@ -144,6 +146,7 @@ static int AStreamRefillBlock(stream_t *s)
{
/* Append the block */
sys->i_size += b->i_buffer;
+ sys->i_alloc_size += b->i_size;
*sys->pp_last = b;
sys->pp_last = &b->p_next;
@@ -203,6 +206,7 @@ static void AStreamPrebufferBlock(stream_t *s)
{
/* Append the block */
sys->i_size += b->i_buffer;
+ sys->i_alloc_size += b->i_size;
*sys->pp_last = b;
sys->pp_last = &b->p_next;
@@ -472,6 +476,7 @@ static int Open(vlc_object_t *obj)
sys->i_offset = 0;
sys->p_current = NULL;
sys->i_size = 0;
+ sys->i_alloc_size = 0;
sys->p_first = NULL;
sys->pp_last = &sys->p_first;
--
2.5.0
More information about the vlc-devel
mailing list