revision 1121:c2d827cbdf37
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 1121:c2d827cbdf37 |
parent | 1120:7c40a0f687b3 |
child | 1122:93d07b7d0ac6 |
author | nkeynes |
date | Fri Sep 10 21:42:41 2010 +1000 (11 years ago) |
Close tmpfiles at exit rather than destroying them, to avoid triggering the assertion
due to the source still being referenced
due to the source still being referenced
1.1 --- a/src/drivers/cdrom/sector.c Fri Sep 10 08:50:55 2010 +10001.2 +++ b/src/drivers/cdrom/sector.c Fri Sep 10 21:42:41 2010 +10001.3 @@ -551,30 +551,40 @@1.4 static GList *tmpfile_open_list = NULL;1.5 static gboolean tmpfile_atexit_installed = 0; /* TRUE to indicate atexit hook is registered */1.7 +static void tmpfile_sector_close( sector_source_t dev )1.8 +{1.9 + assert( IS_SECTOR_SOURCE_TYPE(dev,FILE_SECTOR_SOURCE) );1.10 + tmpfile_sector_source_t fdev = (tmpfile_sector_source_t)dev;1.11 +1.12 + if( fdev->file.file != NULL ) {1.13 + fclose( fdev->file.file );1.14 + fdev->file.file = NULL;1.15 + }1.16 + if( fdev->filename != NULL ) {1.17 + unlink(fdev->filename);1.18 + g_free((char *)fdev->filename);1.19 + fdev->filename = NULL;1.20 + }1.21 +}1.22 +1.23 +1.24 /**1.25 - * atexit hook to destroy any open tmpfiles - make sure they're deleted.1.26 + * atexit hook to close any open tmpfiles - make sure they're deleted.1.27 */1.28 static void tmpfile_atexit_hook(void)1.29 {1.30 GList *ptr;1.31 - while( tmpfile_open_list != NULL ) {1.32 - sector_source_t source = (sector_source_t)tmpfile_open_list->data;1.33 - source->destroy(source);1.34 - assert( tmpfile_open_list == NULL || tmpfile_open_list->data != source );1.35 + for( ptr = tmpfile_open_list; ptr != NULL; ptr = ptr->next ) {1.36 + sector_source_t source = (sector_source_t)ptr->data;1.37 + tmpfile_sector_close(source);1.38 }1.39 }1.42 static void tmpfile_sector_source_destroy( sector_source_t dev )1.43 {1.44 - assert( IS_SECTOR_SOURCE_TYPE(dev,FILE_SECTOR_SOURCE) );1.45 - tmpfile_sector_source_t fdev = (tmpfile_sector_source_t)dev;1.46 -1.47 - fclose( fdev->file.file );1.48 - fdev->file.file = NULL;1.49 - unlink(fdev->filename);1.50 - g_free((char *)fdev->filename);1.51 - tmpfile_open_list = g_list_remove(tmpfile_open_list, fdev);1.52 + tmpfile_sector_close(dev);1.53 + tmpfile_open_list = g_list_remove(tmpfile_open_list, dev);1.54 default_sector_source_destroy(dev);1.55 }
.