make sure to keep a ref to jobs while they run in a thread

Origin: vendor, Ubuntu

Gbp-Pq: Name ref-jobs-in-thread.patch
This commit is contained in:
Michael Terry 2012-04-12 15:14:55 -04:00 committed by luzp
parent 665afde7a8
commit 7398230497
2 changed files with 8 additions and 4 deletions

View File

@ -644,6 +644,7 @@ send_reply_cb (GObject *source_object,
}
g_object_unref (job);
g_object_unref (channel);
}
/* Might be called on an i/o thread */
@ -667,7 +668,7 @@ g_vfs_channel_send_reply (GVfsChannel *channel,
channel->priv->reply_buffer,
G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE,
0, NULL,
send_reply_cb, channel);
send_reply_cb, g_object_ref (channel));
}
else
{
@ -676,7 +677,7 @@ g_vfs_channel_send_reply (GVfsChannel *channel,
channel->priv->output_data,
channel->priv->output_data_size,
0, NULL,
send_reply_cb, channel);
send_reply_cb, g_object_ref (channel));
}
}

View File

@ -209,6 +209,7 @@ job_handler_callback (gpointer data,
GVfsJob *job = G_VFS_JOB (data);
g_vfs_job_run (job);
g_object_unref (job);
}
static void
@ -648,7 +649,8 @@ g_vfs_daemon_queue_job (GVfsDaemon *daemon,
if (!g_vfs_job_try (job))
{
/* Couldn't finish / run async, queue worker thread */
g_thread_pool_push (daemon->thread_pool, job, NULL); /* TODO: Check error */
if (!g_thread_pool_push (daemon->thread_pool, g_object_ref (job), NULL)) /* TODO: Check error */
g_object_unref (job);
}
}
@ -1169,7 +1171,8 @@ void
g_vfs_daemon_run_job_in_thread (GVfsDaemon *daemon,
GVfsJob *job)
{
g_thread_pool_push (daemon->thread_pool, job, NULL); /* TODO: Check error */
if (!g_thread_pool_push (daemon->thread_pool, g_object_ref (job), NULL)) /* TODO: Check error */
g_object_unref (job);
}
void