From d5c88bc058a71ca3833f5e145a1c789b09eb7048 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 18 Aug 2004 10:22:34 +0000 Subject: [PATCH] gst/tcp/gstfdset.c: Realloc test fdset in the lock and right before starting the poll call. Bump the limit to 4096. Original commit message from CVS: * gst/tcp/gstfdset.c: (ensure_size), (gst_fdset_wait): Realloc test fdset in the lock and right before starting the poll call. Bump the limit to 4096. --- gst/tcp/gstfdset.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gst/tcp/gstfdset.c b/gst/tcp/gstfdset.c index ebd10e1..8496f32 100644 --- a/gst/tcp/gstfdset.c +++ b/gst/tcp/gstfdset.c @@ -20,7 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#define MIN_POLLFDS 64 +#define MIN_POLLFDS 4096 #define INIT_POLLFDS MIN_POLLFDS #include @@ -55,10 +55,12 @@ struct _GstFDSet /* for poll */ struct pollfd *testpollfds; + gint testsize; + struct pollfd *pollfds; - gint last_pollfds; gint size; gint free; + gint last_pollfds; GMutex *poll_lock; /* for select */ @@ -87,7 +89,6 @@ ensure_size (GstFDSet * set, gint len) need = MAX (need, MIN_POLLFDS * sizeof (struct pollfd)); set->pollfds = g_realloc (set->pollfds, need); - set->testpollfds = g_realloc (set->testpollfds, need); set->size = need; } @@ -395,6 +396,10 @@ gst_fdset_wait (GstFDSet * set, int timeout) gint last_pollfds; g_mutex_lock (set->poll_lock); + if (set->testsize != set->size) { + set->testpollfds = g_realloc (set->testpollfds, set->size); + set->testsize = set->size; + } last_pollfds = set->last_pollfds; memcpy (set->testpollfds, set->pollfds, sizeof (struct pollfd) * last_pollfds); -- 2.7.4