[brasero/gnome-2-28] Don't leak file descriptors
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [brasero/gnome-2-28] Don't leak file descriptors
- Date: Sat, 26 Sep 2009 12:52:52 +0000 (UTC)
commit 3af0a55b9c9888d68054c851e14861acfdb51453
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Sat Sep 26 14:49:40 2009 +0200
Don't leak file descriptors
This could be the reason why media did not get ejected
libbrasero-media/brasero-drive.c | 20 +++++++----
libbrasero-media/brasero-medium.c | 64 ++++++++++++++++++++-----------------
2 files changed, 48 insertions(+), 36 deletions(-)
---
diff --git a/libbrasero-media/brasero-drive.c b/libbrasero-media/brasero-drive.c
index 08ab4e7..f3a7136 100644
--- a/libbrasero-media/brasero-drive.c
+++ b/libbrasero-media/brasero-drive.c
@@ -810,7 +810,7 @@ brasero_drive_probe_inside_thread (gpointer data)
const gchar *device;
BraseroScsiErrCode code;
BraseroDrivePrivate *priv;
- BraseroDeviceHandle *handle;
+ BraseroDeviceHandle *handle = NULL;
BraseroDrive *drive = BRASERO_DRIVE (data);
priv = BRASERO_DRIVE_PRIVATE (drive);
@@ -833,13 +833,15 @@ brasero_drive_probe_inside_thread (gpointer data)
handle = brasero_device_handle_open (device, FALSE, &code);
}
- if (priv->probe_cancelled) {
- BRASERO_MEDIA_LOG ("Open () cancelled");
+ if (!handle) {
+ BRASERO_MEDIA_LOG ("Open () failed: medium busy");
goto end;
}
- if (!handle) {
- BRASERO_MEDIA_LOG ("Open () failed: medium busy");
+ if (priv->probe_cancelled) {
+ BRASERO_MEDIA_LOG ("Open () cancelled");
+
+ brasero_device_handle_close (handle);
goto end;
}
@@ -848,20 +850,24 @@ brasero_drive_probe_inside_thread (gpointer data)
BRASERO_MEDIA_LOG ("No medium inserted");
priv->has_medium = FALSE;
+
+ brasero_device_handle_close (handle);
goto end;
}
if (code != BRASERO_SCSI_NOT_READY) {
- brasero_device_handle_close (handle);
BRASERO_MEDIA_LOG ("Device does not respond");
+
+ brasero_device_handle_close (handle);
goto end;
}
sleep (2);
if (priv->probe_cancelled) {
- brasero_device_handle_close (handle);
BRASERO_MEDIA_LOG ("Device probing cancelled");
+
+ brasero_device_handle_close (handle);
goto end;
}
}
diff --git a/libbrasero-media/brasero-medium.c b/libbrasero-media/brasero-medium.c
index 46762d4..88a801d 100644
--- a/libbrasero-media/brasero-medium.c
+++ b/libbrasero-media/brasero-medium.c
@@ -2978,43 +2978,49 @@ brasero_medium_probe_thread (gpointer self)
handle = brasero_device_handle_open (device, FALSE, &code);
}
- if (priv->probe_cancelled)
+ if (!handle) {
+ BRASERO_MEDIA_LOG ("Open () failed: medium busy");
goto end;
+ }
- if (handle) {
- BRASERO_MEDIA_LOG ("Open () succeeded");
-
- /* NOTE: if we wanted to know the status we'd need to read the
- * error code variable which is currently NULL */
- while (brasero_spc1_test_unit_ready (handle, &code) != BRASERO_SCSI_OK) {
- if (code == BRASERO_SCSI_NO_MEDIUM) {
- brasero_device_handle_close (handle);
- BRASERO_MEDIA_LOG ("No medium inserted");
- priv->info = BRASERO_MEDIUM_NONE;
- goto end;
- }
- else if (code != BRASERO_SCSI_NOT_READY) {
- brasero_device_handle_close (handle);
- BRASERO_MEDIA_LOG ("Device does not respond");
- goto end;
- }
+ if (priv->probe_cancelled) {
+ brasero_device_handle_close (handle);
+ goto end;
+ }
- sleep (2);
+ BRASERO_MEDIA_LOG ("Open () succeeded");
- if (priv->probe_cancelled) {
- brasero_device_handle_close (handle);
- BRASERO_MEDIA_LOG ("Device probing cancelled");
- goto end;
- }
+ /* NOTE: if we wanted to know the status we'd need to read the
+ * error code variable which is currently NULL */
+ while (brasero_spc1_test_unit_ready (handle, &code) != BRASERO_SCSI_OK) {
+ if (code == BRASERO_SCSI_NO_MEDIUM) {
+ BRASERO_MEDIA_LOG ("No medium inserted");
+ priv->info = BRASERO_MEDIUM_NONE;
+
+ brasero_device_handle_close (handle);
+ goto end;
}
+ else if (code != BRASERO_SCSI_NOT_READY) {
+ BRASERO_MEDIA_LOG ("Device does not respond");
- BRASERO_MEDIA_LOG ("Device ready");
+ brasero_device_handle_close (handle);
+ goto end;
+ }
- brasero_medium_init_real (BRASERO_MEDIUM (self), handle);
- brasero_device_handle_close (handle);
+ sleep (2);
+
+ if (priv->probe_cancelled) {
+ BRASERO_MEDIA_LOG ("Device probing cancelled");
+
+ brasero_device_handle_close (handle);
+ goto end;
+ }
}
- else
- BRASERO_MEDIA_LOG ("Open () failed: medium busy");
+
+ BRASERO_MEDIA_LOG ("Device ready");
+
+ brasero_medium_init_real (BRASERO_MEDIUM (self), handle);
+ brasero_device_handle_close (handle);
end:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]