Commit 3bc14c44 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler
Browse files

Used the fixed-up gnome_vfs_shutdown to properly synchronize with GnomeVFS

2000-05-27  Pavel Cisler  <pavel@eazel.com>

	* src/nautilus-application.c: (nautilus_app_quit):
	Used the fixed-up gnome_vfs_shutdown to properly synchronize
	with GnomeVFS threads that are still finishing up. Got rid of
	nautilus_app_real_quit and the other hacky code that I used
	to do this before gnome_vfs_shutdown was working properly.
	Got rid of a bunch of FIXMEs that are now take care of.

	* libnautilus-extensions/nautilus-directory-async.c:
	(cancel_directory_counts), (top_left_read_close),
	(cancel_top_left_read), (nautilus_metafile_read_cancel),
	(start_getting_directory_counts), (start_getting_top_lefts):
	Added cancel calls to the different GnomeVFS async tasks that
	can be running when opening a Nautilus window, called them
	from the NautilusDirectory destroy call.

	Nautilus now shuts down GnomeVFS jobs cleanly during a quit.
	There is still a problem where in some cases it will take a
	while before the async jobs go away. This seems to be because
	the corresponding NautilusDirectory doesn't get destroyed right
	away when a window is closed. I need to get Darin to help me fix
	this.
parent 57c6a44a
2000-05-27 Pavel Cisler <pavel@eazel.com>
* src/nautilus-application.c: (nautilus_app_quit):
Used the fixed-up gnome_vfs_shutdown to properly synchronize
with GnomeVFS threads that are still finishing up. Got rid of
nautilus_app_real_quit and the other hacky code that I used
to do this before gnome_vfs_shutdown was working properly.
Got rid of a bunch of FIXMEs that are now take care of.
* libnautilus-extensions/nautilus-directory-async.c:
(cancel_directory_counts), (top_left_read_close),
(cancel_top_left_read), (nautilus_metafile_read_cancel),
(start_getting_directory_counts), (start_getting_top_lefts):
Added cancel calls to the different GnomeVFS async tasks that
can be running when opening a Nautilus window, called them
from the NautilusDirectory destroy call.
Nautilus now shuts down GnomeVFS jobs cleanly during a quit.
There is still a problem where in some cases it will take a
while before the async jobs go away. This seems to be because
the corresponding NautilusDirectory doesn't get destroyed right
away when a window is closed. I need to get Darin to help me fix
this.
2000-05-27 Eskil Heyn Olsen <eskil@eazel.com> 2000-05-27 Eskil Heyn Olsen <eskil@eazel.com>
* components/services/install/lib/eazel-install-object.c: * components/services/install/lib/eazel-install-object.c:
......
...@@ -127,18 +127,53 @@ metafile_read_close (NautilusDirectory *directory) ...@@ -127,18 +127,53 @@ metafile_read_close (NautilusDirectory *directory)
directory->details->metafile_read_state->handle = NULL; directory->details->metafile_read_state->handle = NULL;
} }
void static void
nautilus_metafile_read_cancel (NautilusDirectory *directory) cancel_directory_counts (NautilusDirectory *directory)
{ {
if (directory->details->metafile_read_state == NULL) { if (directory->details->count_in_progress != NULL) {
return; gnome_vfs_async_cancel (directory->details->count_in_progress);
directory->details->count_file = NULL;
directory->details->count_in_progress = NULL;
}
}
static void
top_left_read_close (NautilusDirectory *directory)
{
g_assert (directory->details->top_left_read_state->handle != NULL);
if (directory->details->top_left_read_state->is_open) {
gnome_vfs_async_close (directory->details->top_left_read_state->handle,
empty_close_callback,
directory);
directory->details->top_left_read_state->is_open = FALSE;
}
directory->details->top_left_read_state->handle = NULL;
}
static void
cancel_top_left_read (NautilusDirectory *directory)
{
if (directory->details->top_left_read_state != NULL) {
gnome_vfs_async_cancel (directory->details->top_left_read_state->handle);
top_left_read_close (directory);
g_free (directory->details->top_left_read_state->buffer);
g_free (directory->details->top_left_read_state);
directory->details->top_left_read_state = NULL;
} }
}
void
nautilus_metafile_read_cancel (NautilusDirectory *directory)
{
if (directory->details->metafile_read_state != NULL) {
g_assert (directory->details->metafile_read_state->handle != NULL); g_assert (directory->details->metafile_read_state->handle != NULL);
gnome_vfs_async_cancel (directory->details->metafile_read_state->handle); gnome_vfs_async_cancel (directory->details->metafile_read_state->handle);
metafile_read_close (directory); metafile_read_close (directory);
g_free (directory->details->metafile_read_state); g_free (directory->details->metafile_read_state);
directory->details->metafile_read_state = NULL; directory->details->metafile_read_state = NULL;
}
cancel_directory_counts (directory);
cancel_top_left_read (directory);
} }
static void static void
...@@ -1436,9 +1471,7 @@ start_getting_directory_counts (NautilusDirectory *directory) ...@@ -1436,9 +1471,7 @@ start_getting_directory_counts (NautilusDirectory *directory)
} }
/* The count is not wanted, so stop it. */ /* The count is not wanted, so stop it. */
gnome_vfs_async_cancel (directory->details->count_in_progress); cancel_directory_counts (directory);
directory->details->count_file = NULL;
directory->details->count_in_progress = NULL;
} }
/* Figure out which file to get a count for. */ /* Figure out which file to get a count for. */
...@@ -1516,19 +1549,6 @@ top_left_read_complete (NautilusDirectory *directory) ...@@ -1516,19 +1549,6 @@ top_left_read_complete (NautilusDirectory *directory)
top_left_read_done (directory); top_left_read_done (directory);
} }
static void
top_left_read_close (NautilusDirectory *directory)
{
g_assert (directory->details->top_left_read_state->handle != NULL);
if (directory->details->top_left_read_state->is_open) {
gnome_vfs_async_close (directory->details->top_left_read_state->handle,
empty_close_callback,
directory);
directory->details->top_left_read_state->is_open = FALSE;
}
directory->details->top_left_read_state->handle = NULL;
}
static void static void
top_left_read_callback (GnomeVFSAsyncHandle *handle, top_left_read_callback (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result, GnomeVFSResult result,
...@@ -1625,11 +1645,7 @@ start_getting_top_lefts (NautilusDirectory *directory) ...@@ -1625,11 +1645,7 @@ start_getting_top_lefts (NautilusDirectory *directory)
} }
/* The top left is not wanted, so stop it. */ /* The top left is not wanted, so stop it. */
gnome_vfs_async_cancel (directory->details->top_left_read_state->handle); cancel_top_left_read (directory);
top_left_read_close (directory);
g_free (directory->details->top_left_read_state->buffer);
g_free (directory->details->top_left_read_state);
directory->details->top_left_read_state = NULL;
} }
/* Figure out which file to read the top left for. */ /* Figure out which file to read the top left for. */
......
...@@ -127,18 +127,53 @@ metafile_read_close (NautilusDirectory *directory) ...@@ -127,18 +127,53 @@ metafile_read_close (NautilusDirectory *directory)
directory->details->metafile_read_state->handle = NULL; directory->details->metafile_read_state->handle = NULL;
} }
void static void
nautilus_metafile_read_cancel (NautilusDirectory *directory) cancel_directory_counts (NautilusDirectory *directory)
{ {
if (directory->details->metafile_read_state == NULL) { if (directory->details->count_in_progress != NULL) {
return; gnome_vfs_async_cancel (directory->details->count_in_progress);
directory->details->count_file = NULL;
directory->details->count_in_progress = NULL;
}
}
static void
top_left_read_close (NautilusDirectory *directory)
{
g_assert (directory->details->top_left_read_state->handle != NULL);
if (directory->details->top_left_read_state->is_open) {
gnome_vfs_async_close (directory->details->top_left_read_state->handle,
empty_close_callback,
directory);
directory->details->top_left_read_state->is_open = FALSE;
}
directory->details->top_left_read_state->handle = NULL;
}
static void
cancel_top_left_read (NautilusDirectory *directory)
{
if (directory->details->top_left_read_state != NULL) {
gnome_vfs_async_cancel (directory->details->top_left_read_state->handle);
top_left_read_close (directory);
g_free (directory->details->top_left_read_state->buffer);
g_free (directory->details->top_left_read_state);
directory->details->top_left_read_state = NULL;
} }
}
void
nautilus_metafile_read_cancel (NautilusDirectory *directory)
{
if (directory->details->metafile_read_state != NULL) {
g_assert (directory->details->metafile_read_state->handle != NULL); g_assert (directory->details->metafile_read_state->handle != NULL);
gnome_vfs_async_cancel (directory->details->metafile_read_state->handle); gnome_vfs_async_cancel (directory->details->metafile_read_state->handle);
metafile_read_close (directory); metafile_read_close (directory);
g_free (directory->details->metafile_read_state); g_free (directory->details->metafile_read_state);
directory->details->metafile_read_state = NULL; directory->details->metafile_read_state = NULL;
}
cancel_directory_counts (directory);
cancel_top_left_read (directory);
} }
static void static void
...@@ -1436,9 +1471,7 @@ start_getting_directory_counts (NautilusDirectory *directory) ...@@ -1436,9 +1471,7 @@ start_getting_directory_counts (NautilusDirectory *directory)
} }
/* The count is not wanted, so stop it. */ /* The count is not wanted, so stop it. */
gnome_vfs_async_cancel (directory->details->count_in_progress); cancel_directory_counts (directory);
directory->details->count_file = NULL;
directory->details->count_in_progress = NULL;
} }
/* Figure out which file to get a count for. */ /* Figure out which file to get a count for. */
...@@ -1516,19 +1549,6 @@ top_left_read_complete (NautilusDirectory *directory) ...@@ -1516,19 +1549,6 @@ top_left_read_complete (NautilusDirectory *directory)
top_left_read_done (directory); top_left_read_done (directory);
} }
static void
top_left_read_close (NautilusDirectory *directory)
{
g_assert (directory->details->top_left_read_state->handle != NULL);
if (directory->details->top_left_read_state->is_open) {
gnome_vfs_async_close (directory->details->top_left_read_state->handle,
empty_close_callback,
directory);
directory->details->top_left_read_state->is_open = FALSE;
}
directory->details->top_left_read_state->handle = NULL;
}
static void static void
top_left_read_callback (GnomeVFSAsyncHandle *handle, top_left_read_callback (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result, GnomeVFSResult result,
...@@ -1625,11 +1645,7 @@ start_getting_top_lefts (NautilusDirectory *directory) ...@@ -1625,11 +1645,7 @@ start_getting_top_lefts (NautilusDirectory *directory)
} }
/* The top left is not wanted, so stop it. */ /* The top left is not wanted, so stop it. */
gnome_vfs_async_cancel (directory->details->top_left_read_state->handle); cancel_top_left_read (directory);
top_left_read_close (directory);
g_free (directory->details->top_left_read_state->buffer);
g_free (directory->details->top_left_read_state);
directory->details->top_left_read_state = NULL;
} }
/* Figure out which file to read the top left for. */ /* Figure out which file to read the top left for. */
......
...@@ -363,46 +363,11 @@ nautilus_app_destroy_window (GtkObject *obj, NautilusApp *app) ...@@ -363,46 +363,11 @@ nautilus_app_destroy_window (GtkObject *obj, NautilusApp *app)
} }
} }
/* FIXME: If we are really going to use this, it should probably be
* moved to the gnome vfs public interface (which would change its
* name to not include "debug").
*/
extern int gnome_vfs_debug_get_thread_count (void);
int quit_counter_hack;
/* FIXME: This waiting for quit is needed by anyone who uses gnome-vfs,
* especially users or NautilusDirectory. So we need to provide it for
* others who are not using NautilusApp.
*/
static gboolean
nautilus_app_real_quit (void *unused)
{
int count;
count = gnome_vfs_debug_get_thread_count ();
if (count == 0) {
/* g_message ("no more gnome vfs threads, ready to quit"); */
gtk_main_quit ();
return FALSE;
}
if (--quit_counter_hack == 0) {
g_message ("gnome vfs threads not going away, trying to quit anyway");
gtk_main_quit ();
return FALSE;
}
/* g_message ("%d gnome vfs threads left, will try to quit later", count); */
usleep(200000); /* 1/5 second */
return TRUE;
}
void void
nautilus_app_quit (void) nautilus_app_quit (void)
{ {
quit_counter_hack = 20; /* 20 * 1/5 second == 4 seconds */ gnome_vfs_shutdown ();
gtk_main_quit ();
/* wait for gnome vfs slave threads to go away before quitting */
gtk_idle_add ((GtkFunction)nautilus_app_real_quit, NULL);
} }
NautilusWindow * NautilusWindow *
......
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