Commit d44aa74e authored by Olivier Crête's avatar Olivier Crête

pseudotcp: Don't keep refs on sources

This was causing sources to all be kept until the pseudo tcp connection
grew too big. This could caused the sources to accumulate in the GMainContext.
parent 72c67c4e
......@@ -1109,7 +1109,7 @@ pseudo_tcp_socket_init (PseudoTcpSocket *obj)
priv->support_wnd_scale = TRUE;
priv->support_fin_ack = TRUE;
priv->sources = g_ptr_array_new_with_free_func ((GDestroyNotify) g_source_unref);
priv->sources = g_ptr_array_new ();
priv->retries1 = DEFAULT_RETRIES1;
priv->retries2 = DEFAULT_RETRIES2;
......@@ -1204,7 +1204,7 @@ pseudo_tcp_socket_create_source (PseudoTcpSocket *self,
"Created pseudo-TCP source %p with condition %u.",
source, condition);
g_rec_mutex_lock (&self->priv->mutex);
g_ptr_array_add (priv->sources, g_source_ref (source));
g_ptr_array_add (priv->sources, source);
g_rec_mutex_unlock (&self->priv->mutex);
return source;
......@@ -3830,7 +3830,8 @@ pseudo_tcp_source_update (PseudoTcpSocket *self,
/* Some new events set? Schedule a dispatch. Otherwise clear any scheduled
* dispatches. */
if (pseudo_tcp_source->pending_condition != prev_pending_condition) {
if (pseudo_tcp_source->pending_condition != prev_pending_condition &&
!g_source_is_destroyed ((GSource *) pseudo_tcp_source)) {
if (pseudo_tcp_source->pending_condition) {
#if 0
DEBUG (PSEUDO_TCP_DEBUG_NORMAL, "Scheduling source %p.",
......@@ -3884,6 +3885,16 @@ static void
pseudo_tcp_source_finalize (GSource *source)
{
PseudoTcpSource *pseudo_tcp_source = (PseudoTcpSource *) source;
PseudoTcpSocket *self = g_weak_ref_get (&pseudo_tcp_source->socket_ref);
if (self) {
PseudoTcpSocketPrivate *priv = self->priv;
g_rec_mutex_lock (&self->priv->mutex);
g_ptr_array_remove (priv->sources, source);
g_rec_mutex_unlock (&self->priv->mutex);
g_object_unref (self);
}
g_weak_ref_clear (&pseudo_tcp_source->socket_ref);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment