From 1b18c619f05914bf747130efd700b7ce13129724 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 7 Feb 2008 21:15:09 +0000 Subject: [PATCH] Stuffed memory leak with read cache. Economized on error retries. --- libisoburn/trunk/libisoburn/data_source.c | 28 +++++++++++++++++--- libisoburn/trunk/xorriso/xorriso_timestamp.h | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/libisoburn/trunk/libisoburn/data_source.c b/libisoburn/trunk/libisoburn/data_source.c index 256d0e46..87ebc471 100644 --- a/libisoburn/trunk/libisoburn/data_source.c +++ b/libisoburn/trunk/libisoburn/data_source.c @@ -38,6 +38,8 @@ struct isoburn_cached_drive { char cache_data[Libisoburn_cache_blockS * 2048]; uint32_t cache_lba; + uint32_t last_error_lba; + uint32_t last_aligned_error_lba; int cache_hits; }; @@ -56,6 +58,7 @@ ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer) struct burn_drive *d; off_t count; uint32_t aligned_lba; + char msg[80]; struct isoburn_cached_drive *icd; @@ -74,15 +77,27 @@ ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer) } icd->cache_lba= 0xffffffff; /* invalidate cache */ - ret = burn_read_data(d, (off_t) aligned_lba * (off_t) 2048, - (char *) icd->cache_data, - Libisoburn_cache_blockS * 2048, &count, 0); + if(icd->last_aligned_error_lba == aligned_lba) { + ret = 0; + } else { + ret = burn_read_data(d, (off_t) aligned_lba * (off_t) 2048, + (char *) icd->cache_data, + Libisoburn_cache_blockS * 2048, &count, 0); + } if (ret <= 0 ) { + icd->last_aligned_error_lba = aligned_lba; + /* Read-ahead failure ? Try to read 2048 directly. */ - ret = burn_read_data(d, (off_t) lba * (off_t) 2048, (char *) buffer, + if(icd->last_error_lba == lba) + ret = 0; + else + ret = burn_read_data(d, (off_t) lba * (off_t) 2048, (char *) buffer, 2048, &count, 0); if (ret > 0) return 1; + icd->last_error_lba = lba; + sprintf(msg, "ds_read_block(%lu) returns -1", (unsigned long) lba); + burn_msgs_submit(0x00060000, msg, 0, "DEBUG", NULL); return -1; } @@ -142,6 +157,9 @@ static void ds_free_data(IsoDataSource *src) { /* nothing to do */; + if(src->data != NULL) + free(src->data); + src->data= NULL; } IsoDataSource * @@ -165,6 +183,8 @@ isoburn_data_source_new(struct burn_drive *d) icd->drive = d; icd->cache_lba = 0xffffffff; icd->cache_hits = 0; + icd->last_error_lba = 0xffffffff; + icd->last_aligned_error_lba = 0xffffffff; return ret; } diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index 5d997de4..d039690d 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.02.07.154947" +#define Xorriso_timestamP "2008.02.07.211424"