Stuffed memory leak with read cache. Economized on error retries.
This commit is contained in:
parent
ee9ffbefe0
commit
1b18c619f0
@ -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 */
|
||||
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. */
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2008.02.07.154947"
|
||||
#define Xorriso_timestamP "2008.02.07.211424"
|
||||
|
Loading…
Reference in New Issue
Block a user