diff options
author | Gene Z. Ragan <gzr@eazel.com> | 2001-04-06 19:31:36 +0000 |
---|---|---|
committer | Gene Ragan <gzr@src.gnome.org> | 2001-04-06 19:31:36 +0000 |
commit | b3ecbf0cab1dd692a48a870ff8676f3284a972b9 (patch) | |
tree | 236378cdc36218522732e101adfbede7f9f17c8b | |
parent | d26dc33a6d19d9551bdef6e2160ec33b11fbedda (diff) | |
download | nautilus-b3ecbf0cab1dd692a48a870ff8676f3284a972b9.tar.gz |
Attempt to track down possible file descriptor leak.
2001-04-06 Gene Z. Ragan <gzr@eazel.com>
Attempt to track down possible file descriptor leak.
* libnautilus-extensions/nautilus-volume-monitor.c:
(get_removable_volumes), (get_current_mount_list),
(open_cdda_device), (locate_audio_cd):
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-volume-monitor.c | 60 | ||||
-rw-r--r-- | libnautilus-private/nautilus-volume-monitor.c | 60 |
3 files changed, 66 insertions, 62 deletions
@@ -1,4 +1,12 @@ 2001-04-06 Gene Z. Ragan <gzr@eazel.com> + + Attempt to track down possible file descriptor leak. + + * libnautilus-extensions/nautilus-volume-monitor.c: + (get_removable_volumes), (get_current_mount_list), + (open_cdda_device), (locate_audio_cd): + +2001-04-06 Gene Z. Ragan <gzr@eazel.com> Add more verbose error message in the case that /proc/mounts or /etc/mnttab cannot be opened. diff --git a/libnautilus-extensions/nautilus-volume-monitor.c b/libnautilus-extensions/nautilus-volume-monitor.c index 48ec6762b..e4a13a860 100644 --- a/libnautilus-extensions/nautilus-volume-monitor.c +++ b/libnautilus-extensions/nautilus-volume-monitor.c @@ -87,6 +87,11 @@ #ifdef HAVE_CDDA_INTERFACE_H #ifdef HAVE_CDDA_PARANOIA_H +#define HAVE_CDDA 1 +#endif +#endif + +#ifdef HAVE_CDDA #define size16 short #define size32 int @@ -106,7 +111,6 @@ char **broken_header_fix = strerror_tr; #endif -#endif #define CHECK_STATUS_INTERVAL 2000 @@ -170,12 +174,10 @@ static void free_mount_list (GList *mount_list); static GList *get_removable_volumes (void); static GHashTable *create_readable_mount_point_name_table (void); -#ifdef HAVE_CDDA_INTERFACE_H -#ifdef HAVE_CDDA_PARANOIA_H +#ifdef HAVE_CDDA static cdrom_drive *open_cdda_device (GnomeVFSURI *uri); static gboolean locate_audio_cd (void); #endif -#endif #ifdef SOLARIS_MNT static int get_cdrom_type_solaris (const char *vol_dev_path, @@ -393,12 +395,10 @@ get_removable_volumes (void) fclose (file); -#ifdef HAVE_CDDA_INTERFACE_H -#ifdef HAVE_CDDA_PARANOIA_H +#ifdef HAVE_CDDA volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH, CDDA_SCHEME); volumes = mount_volume_add_filesystem (volume, volumes); #endif -#endif /* Move all floppy mounts to top of list */ return g_list_sort (g_list_reverse (volumes), (GCompareFunc) floppy_sort); @@ -998,8 +998,7 @@ get_current_mount_list (void) fclose (fh); } -#ifdef HAVE_CDDA_INTERFACE_H -#ifdef HAVE_CDDA_PARANOIA_H +#ifdef HAVE_CDDA /* CD Audio tricks */ if (locate_audio_cd ()) { volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH, CDDA_SCHEME); @@ -1007,7 +1006,6 @@ get_current_mount_list (void) current_mounts = mount_volume_add_filesystem (volume, current_mounts); } #endif -#endif return current_mounts; } @@ -1913,20 +1911,22 @@ nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monit } } -#ifdef HAVE_CDDA_INTERFACE_H -#ifdef HAVE_CDDA_PARANOIA_H +#ifdef HAVE_CDDA -static cdrom_drive * +static gboolean open_cdda_device (GnomeVFSURI *uri) { const char *device_name; cdrom_drive *drive; + gboolean opened; + + g_message ("open_cdda_device"); device_name = gnome_vfs_uri_get_path (uri); drive = cdda_identify (device_name, FALSE, NULL); if (drive == NULL) { - return NULL; + return FALSE; } /* Turn off verbosity */ @@ -1939,46 +1939,44 @@ open_cdda_device (GnomeVFSURI *uri) case -4: case -5: /*g_message ("Unable to open disc. Is there an audio CD in the drive?");*/ - return NULL; - + opened = FALSE; + break; + case -6: /*g_message ("CDDA method could not find a way to read audio from this drive.");*/ - return NULL; + opened = FALSE; + break; case 0: + opened = TRUE; break; default: /*g_message ("Unable to open disc.");*/ - return NULL; + opened = FALSE; + break; + } + cdda_close (drive); - return drive; + return opened; } static gboolean locate_audio_cd (void) { - cdrom_drive *drive; GnomeVFSURI *uri; - gboolean found_one; + gboolean found_drive; - found_one = FALSE; - uri = gnome_vfs_uri_new (CD_AUDIO_URI); if (uri == NULL) { return found_one; } - drive = open_cdda_device (uri); + found_drive = open_cdda_device (uri); gnome_vfs_uri_unref (uri); - if (drive != NULL) { - found_one = TRUE; - cdda_close (drive); - } - - return found_one; + return found_drive; } #endif -#endif + diff --git a/libnautilus-private/nautilus-volume-monitor.c b/libnautilus-private/nautilus-volume-monitor.c index 48ec6762b..e4a13a860 100644 --- a/libnautilus-private/nautilus-volume-monitor.c +++ b/libnautilus-private/nautilus-volume-monitor.c @@ -87,6 +87,11 @@ #ifdef HAVE_CDDA_INTERFACE_H #ifdef HAVE_CDDA_PARANOIA_H +#define HAVE_CDDA 1 +#endif +#endif + +#ifdef HAVE_CDDA #define size16 short #define size32 int @@ -106,7 +111,6 @@ char **broken_header_fix = strerror_tr; #endif -#endif #define CHECK_STATUS_INTERVAL 2000 @@ -170,12 +174,10 @@ static void free_mount_list (GList *mount_list); static GList *get_removable_volumes (void); static GHashTable *create_readable_mount_point_name_table (void); -#ifdef HAVE_CDDA_INTERFACE_H -#ifdef HAVE_CDDA_PARANOIA_H +#ifdef HAVE_CDDA static cdrom_drive *open_cdda_device (GnomeVFSURI *uri); static gboolean locate_audio_cd (void); #endif -#endif #ifdef SOLARIS_MNT static int get_cdrom_type_solaris (const char *vol_dev_path, @@ -393,12 +395,10 @@ get_removable_volumes (void) fclose (file); -#ifdef HAVE_CDDA_INTERFACE_H -#ifdef HAVE_CDDA_PARANOIA_H +#ifdef HAVE_CDDA volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH, CDDA_SCHEME); volumes = mount_volume_add_filesystem (volume, volumes); #endif -#endif /* Move all floppy mounts to top of list */ return g_list_sort (g_list_reverse (volumes), (GCompareFunc) floppy_sort); @@ -998,8 +998,7 @@ get_current_mount_list (void) fclose (fh); } -#ifdef HAVE_CDDA_INTERFACE_H -#ifdef HAVE_CDDA_PARANOIA_H +#ifdef HAVE_CDDA /* CD Audio tricks */ if (locate_audio_cd ()) { volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH, CDDA_SCHEME); @@ -1007,7 +1006,6 @@ get_current_mount_list (void) current_mounts = mount_volume_add_filesystem (volume, current_mounts); } #endif -#endif return current_mounts; } @@ -1913,20 +1911,22 @@ nautilus_volume_monitor_get_mount_name_for_display (NautilusVolumeMonitor *monit } } -#ifdef HAVE_CDDA_INTERFACE_H -#ifdef HAVE_CDDA_PARANOIA_H +#ifdef HAVE_CDDA -static cdrom_drive * +static gboolean open_cdda_device (GnomeVFSURI *uri) { const char *device_name; cdrom_drive *drive; + gboolean opened; + + g_message ("open_cdda_device"); device_name = gnome_vfs_uri_get_path (uri); drive = cdda_identify (device_name, FALSE, NULL); if (drive == NULL) { - return NULL; + return FALSE; } /* Turn off verbosity */ @@ -1939,46 +1939,44 @@ open_cdda_device (GnomeVFSURI *uri) case -4: case -5: /*g_message ("Unable to open disc. Is there an audio CD in the drive?");*/ - return NULL; - + opened = FALSE; + break; + case -6: /*g_message ("CDDA method could not find a way to read audio from this drive.");*/ - return NULL; + opened = FALSE; + break; case 0: + opened = TRUE; break; default: /*g_message ("Unable to open disc.");*/ - return NULL; + opened = FALSE; + break; + } + cdda_close (drive); - return drive; + return opened; } static gboolean locate_audio_cd (void) { - cdrom_drive *drive; GnomeVFSURI *uri; - gboolean found_one; + gboolean found_drive; - found_one = FALSE; - uri = gnome_vfs_uri_new (CD_AUDIO_URI); if (uri == NULL) { return found_one; } - drive = open_cdda_device (uri); + found_drive = open_cdda_device (uri); gnome_vfs_uri_unref (uri); - if (drive != NULL) { - found_one = TRUE; - cdda_close (drive); - } - - return found_one; + return found_drive; } #endif -#endif + |