Permalink
Browse files

shrink queues to min queue size for special case

it is hard to know what the largest listener lag is now (no refcounts), so we
have to allow up to the queue size but if there are no listeners then we can
definitely shrink it.
  • Loading branch information...
1 parent 3040756 commit c794e15a645e8ef7242149da56843863a73b0b6a @karlheyes committed Jun 8, 2012
Showing with 7 additions and 5 deletions.
  1. +6 −3 src/source.c
  2. +1 −2 src/source.h
View
@@ -392,6 +392,7 @@ int source_read (source_t *source)
refbuf_t *refbuf = NULL;
int skip = 1, loop = 1;
time_t current = client->worker->current_time.tv_sec;
+ long queue_size_target;
int fds = 0;
if (global.running != ICE_RUNNING)
@@ -542,14 +543,16 @@ int source_read (source_t *source)
} while (loop);
/* lets see if we have too much data in the queue */
- while (source->queue_size > source->queue_size_limit)
+ if (source->listeners)
+ queue_size_target = source->queue_size_limit;
+ else
+ queue_size_target = source->min_queue_size;
+ while (source->queue_size > queue_size_target)
{
refbuf_t *to_go = source->stream_data;
source->stream_data = to_go->next;
source->queue_size -= to_go->len;
to_go->next = NULL;
- /* mark for delete to tell others holding it and release it ourselves */
- to_go->flags |= SOURCE_BLOCK_RELEASE;
refbuf_release (to_go);
}
} while (0);
View
@@ -114,8 +114,7 @@ void source_set_fallback (source_t *source, const char *dest_mount);
void source_listeners_wakeup (source_t *source);
#define SOURCE_BLOCK_SYNC 01
-#define SOURCE_BLOCK_RELEASE 02
-#define SOURCE_QUEUE_BLOCK 04
+#define SOURCE_QUEUE_BLOCK 02
#endif

0 comments on commit c794e15

Please sign in to comment.