[rhythmbox: 1/2] encoder: fix missing unref on gtask object in some code paths




commit bccb25e3aee98cc4b81900602cc1932974b1a550
Author: crvi <crvisqr gmail com>
Date:   Sun Mar 28 04:03:34 2021 +0530

    encoder: fix missing unref on gtask object in some code paths
    
    We are not unreffing gtask in some code paths. Here, we do it
    immediately after g_task_run_in_thread (), as the function takes ref
    to the task and unrefs it when the task is completed.
    
    This was causing the system error "too many open files", as the
    encoder was not getting unreffed, causing the pipeline not getting
    unreffed, causing the gstreamer poll loop not getting unreffed,
    causing the socketpair() used by the poll loop to not close. So, for
    each track transfer, 2 fds were lost, causing the system error when
    the open file count per process crossed the user ulimit of 1024 (
    which normally happens when transferring more than 350 tracks ).

 backends/gstreamer/rb-encoder-gst.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
---
diff --git a/backends/gstreamer/rb-encoder-gst.c b/backends/gstreamer/rb-encoder-gst.c
index b9551216c..48c64deae 100644
--- a/backends/gstreamer/rb-encoder-gst.c
+++ b/backends/gstreamer/rb-encoder-gst.c
@@ -649,7 +649,6 @@ sink_open (GTask *task, gpointer source_object, gpointer task_data, GCancellable
                                     _("Could not create a temporary file to write to: %s"),
                                    error->message);
                        g_task_return_error (task, error);
-                       g_object_unref (task);
                        return;
                }
 
@@ -708,7 +707,6 @@ sink_open (GTask *task, gpointer source_object, gpointer task_data, GCancellable
        } else {
                g_task_return_boolean (task, TRUE);
        }
-       g_object_unref (task);
 }
 
 static void
@@ -762,6 +760,7 @@ impl_encode (RBEncoder *bencoder,
 
                task = g_task_new (encoder, encoder->priv->open_cancel, sink_open_cb, NULL);
                g_task_run_in_thread (task, sink_open);
+               g_object_unref (task);
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]