gst/tcp/gstmultifdsink.c: Fix crasher when going to NULL multiple times.

Original commit message from CVS:
* gst/tcp/gstmultifdsink.c: (gst_multifdsink_class_init),
(gst_multifdsink_finalize), (multifdsink_hash_remove),
(gst_multifdsink_stop):
Fix crasher when going to NULL multiple times.
This commit is contained in:
Wim Taymans 2005-10-08 08:50:37 +00:00
parent 25a70411d2
commit bd17e7c611
2 changed files with 30 additions and 2 deletions

View file

@ -1,3 +1,10 @@
2005-10-08 Wim Taymans <wim@fluendo.com>
* gst/tcp/gstmultifdsink.c: (gst_multifdsink_class_init),
(gst_multifdsink_finalize), (multifdsink_hash_remove),
(gst_multifdsink_stop):
Fix crasher when going to NULL multiple times.
2005-10-06 Wim Taymans <wim@fluendo.com> 2005-10-06 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_event), * gst-libs/gst/audio/gstbaseaudiosrc.c: (gst_base_audio_src_event),

View file

@ -221,6 +221,7 @@ gst_client_status_get_type (void)
static void gst_multifdsink_base_init (gpointer g_class); static void gst_multifdsink_base_init (gpointer g_class);
static void gst_multifdsink_class_init (GstMultiFdSinkClass * klass); static void gst_multifdsink_class_init (GstMultiFdSinkClass * klass);
static void gst_multifdsink_init (GstMultiFdSink * multifdsink); static void gst_multifdsink_init (GstMultiFdSink * multifdsink);
static void gst_multifdsink_finalize (GObject * object);
static void gst_multifdsink_remove_client_link (GstMultiFdSink * sink, static void gst_multifdsink_remove_client_link (GstMultiFdSink * sink,
GList * link); GList * link);
@ -293,6 +294,7 @@ gst_multifdsink_class_init (GstMultiFdSinkClass * klass)
gobject_class->set_property = gst_multifdsink_set_property; gobject_class->set_property = gst_multifdsink_set_property;
gobject_class->get_property = gst_multifdsink_get_property; gobject_class->get_property = gst_multifdsink_get_property;
gobject_class->finalize = gst_multifdsink_finalize;
g_object_class_install_property (gobject_class, ARG_PROTOCOL, g_object_class_install_property (gobject_class, ARG_PROTOCOL,
g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in", g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
@ -463,6 +465,20 @@ gst_multifdsink_init (GstMultiFdSink * this)
this->sync_method = DEFAULT_SYNC_METHOD; this->sync_method = DEFAULT_SYNC_METHOD;
} }
static void
gst_multifdsink_finalize (GObject * object)
{
GstMultiFdSink *this;
this = GST_MULTIFDSINK (object);
CLIENTS_LOCK_FREE (this);
g_hash_table_destroy (this->fd_hash);
g_array_free (this->bufqueue, TRUE);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
void void
gst_multifdsink_add (GstMultiFdSink * sink, int fd) gst_multifdsink_add (GstMultiFdSink * sink, int fd)
{ {
@ -1721,6 +1737,12 @@ socket_pair:
} }
} }
static gboolean
multifdsink_hash_remove (gpointer key, gpointer value, gpointer data)
{
return TRUE;
}
static gboolean static gboolean
gst_multifdsink_stop (GstBaseSink * bsink) gst_multifdsink_stop (GstBaseSink * bsink)
{ {
@ -1761,9 +1783,8 @@ gst_multifdsink_stop (GstBaseSink * bsink)
gst_fdset_free (this->fdset); gst_fdset_free (this->fdset);
this->fdset = NULL; this->fdset = NULL;
} }
g_hash_table_foreach_remove (this->fd_hash, multifdsink_hash_remove, this);
GST_FLAG_UNSET (this, GST_MULTIFDSINK_OPEN); GST_FLAG_UNSET (this, GST_MULTIFDSINK_OPEN);
CLIENTS_LOCK_FREE (this);
g_hash_table_destroy (this->fd_hash);
return TRUE; return TRUE;
} }