[gvfs] daemon: Add logic to force close active channels
- From: Christian Kellner <gicmo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] daemon: Add logic to force close active channels
- Date: Tue, 7 Jun 2011 12:36:22 +0000 (UTC)
commit e078f0e75203969ef4c7bcbc61bd935d65316cc9
Author: Christian Kellner <gicmo gnome org>
Date: Sun Jun 5 12:57:02 2011 +0200
daemon: Add logic to force close active channels
This includes logic in a GVfsChannel to force close is as well as a
function in the GVfsDaemon to iterate over all active channels and
call the force-close function.
daemon/gvfschannel.c | 29 +++++++++++++++++++++++++++++
daemon/gvfschannel.h | 2 +-
daemon/gvfsdaemon.c | 10 ++++++++++
daemon/gvfsdaemon.h | 2 +-
4 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gvfschannel.c b/daemon/gvfschannel.c
index b5e3d6a..931a857 100644
--- a/daemon/gvfschannel.c
+++ b/daemon/gvfschannel.c
@@ -750,3 +750,32 @@ g_vfs_channel_get_actual_consumer (GVfsChannel *channel)
return channel->priv->actual_consumer;
}
+static void
+free_queued_requests (gpointer data)
+{
+ Request *req = (Request *) data;
+
+ g_free (req->data);
+ g_free (req);
+}
+
+void
+g_vfs_channel_force_close (GVfsChannel *channel)
+{
+ GVfsJob *job;
+ gint fd;
+
+ fd = g_unix_input_stream_get_fd (G_UNIX_INPUT_STREAM (channel->priv->command_stream));
+
+ shutdown (fd, SHUT_RDWR);
+
+ job = channel->priv->current_job;
+
+ if (job)
+ g_vfs_job_cancel (job);
+
+ g_list_free_full (channel->priv->queued_requests, free_queued_requests);
+ channel->priv->queued_requests = NULL;
+
+ g_vfs_job_source_closed (G_VFS_JOB_SOURCE (channel));
+}
diff --git a/daemon/gvfschannel.h b/daemon/gvfschannel.h
index 60b29af..2659d85 100644
--- a/daemon/gvfschannel.h
+++ b/daemon/gvfschannel.h
@@ -84,7 +84,7 @@ void g_vfs_channel_send_reply (GVfsChannel
gsize data_len);
guint32 g_vfs_channel_get_current_seq_nr (GVfsChannel *channel);
GPid g_vfs_channel_get_actual_consumer (GVfsChannel *channel);
-
+void g_vfs_channel_force_close (GVfsChannel *channel);
/* TODO: i/o priority? */
G_END_DECLS
diff --git a/daemon/gvfsdaemon.c b/daemon/gvfsdaemon.c
index 83ba400..9714b39 100644
--- a/daemon/gvfsdaemon.c
+++ b/daemon/gvfsdaemon.c
@@ -1119,3 +1119,13 @@ g_vfs_daemon_run_job_in_thread (GVfsDaemon *daemon,
{
g_thread_pool_push (daemon->thread_pool, job, NULL); /* TODO: Check error */
}
+
+void
+g_vfs_daemon_close_active_channels (GVfsDaemon *daemon)
+{
+ GList *l;
+
+ for (l = daemon->job_sources; l != NULL; l = l->next)
+ if (G_VFS_IS_CHANNEL (l->data))
+ g_vfs_channel_force_close (G_VFS_CHANNEL (l->data));
+}
diff --git a/daemon/gvfsdaemon.h b/daemon/gvfsdaemon.h
index 7934873..58d6dad 100644
--- a/daemon/gvfsdaemon.h
+++ b/daemon/gvfsdaemon.h
@@ -73,7 +73,7 @@ void g_vfs_daemon_initiate_mount (GVfsDaemon *daemon,
GArray *g_vfs_daemon_get_blocking_processes (GVfsDaemon *daemon);
void g_vfs_daemon_run_job_in_thread (GVfsDaemon *daemon,
GVfsJob *job);
-
+void g_vfs_daemon_close_active_channels (GVfsDaemon *daemon);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]