Commit 8fd0791d authored by Kelly Martin's avatar Kelly Martin

don't update a tile's swap file position until the tile's actually been



* app/tile_swap.c (tile_swap_default_out): don't update a tile's swap
  file position until the tile's actually been successfully written
  out

* app/tile_cache.c (tile_cache_zorch_next): add test to make sure tile
  was successfully swapped out before dropping it from the cache

--klm
parent 11e3f61b
1999-10-04 Kelly Lynn Martin <kelly@poverty.bloomington.in.us>
* app/tile_swap.c (tile_swap_default_out): don't update a tile's
swap file position until the tile's actually been successfully
written out
* app/tile_cache.c (tile_cache_zorch_next): add test to make sure
tile was successfully swapped out before dropping it from the
cache
1999-10-04 Sven Neumann <sven@gimp.org>
* plug-ins/helpbrowser/helpbrowser.c: set the title when the
......
......@@ -104,7 +104,6 @@ tile_cache_insert (Tile *tile)
* if there is room in the cache. If not then we'll have
* to make room first. Note: it might be the case that the
* cache is smaller than the size of a tile in which case
* it won't be possible to put it in the cache.
*/
while ((cur_cache_size + max_tile_size) > max_cache_size)
......@@ -249,10 +248,15 @@ tile_cache_zorch_next ()
{
tile_swap_out (tile);
}
g_free (tile->data);
tile->data = NULL;
if (! tile->dirty) {
g_free (tile->data);
tile->data = NULL;
TILE_MUTEX_UNLOCK (tile);
return TRUE;
}
/* unable to swap out tile for some reason */
TILE_MUTEX_UNLOCK (tile);
return TRUE;
return FALSE;
}
#if USE_PTHREADS
......
......@@ -550,18 +550,20 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
int nleft;
off_t offset;
off_t newpos;
bytes = TILE_WIDTH * TILE_HEIGHT * tile->bpp;
rbytes = tile_size (tile);
/* If there is already a valid swap_offset, use it */
if (tile->swap_offset == -1)
tile->swap_offset = tile_swap_find_offset (def_swap_file, fd, bytes);
newpos = tile_swap_find_offset (def_swap_file, fd, bytes);
else
newpos = tile->swap_offset;
if (def_swap_file->cur_position != tile->swap_offset)
if (def_swap_file->cur_position != newpos)
{
def_swap_file->cur_position = tile->swap_offset;
offset = lseek (fd, tile->swap_offset, SEEK_SET);
offset = lseek (fd, newpos, SEEK_SET);
if (offset == -1)
{
if (seek_err_msg)
......@@ -569,6 +571,7 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
seek_err_msg = FALSE;
return;
}
def_swap_file->cur_position = newpos;
}
nleft = rbytes;
......@@ -592,6 +595,7 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
* tile->data is freed in tile_cache_zorch_next
*/
tile->dirty = FALSE;
tile->swap_offset = newpos;
write_err_msg = seek_err_msg = TRUE;
}
......
......@@ -104,7 +104,6 @@ tile_cache_insert (Tile *tile)
* if there is room in the cache. If not then we'll have
* to make room first. Note: it might be the case that the
* cache is smaller than the size of a tile in which case
* it won't be possible to put it in the cache.
*/
while ((cur_cache_size + max_tile_size) > max_cache_size)
......@@ -249,10 +248,15 @@ tile_cache_zorch_next ()
{
tile_swap_out (tile);
}
g_free (tile->data);
tile->data = NULL;
if (! tile->dirty) {
g_free (tile->data);
tile->data = NULL;
TILE_MUTEX_UNLOCK (tile);
return TRUE;
}
/* unable to swap out tile for some reason */
TILE_MUTEX_UNLOCK (tile);
return TRUE;
return FALSE;
}
#if USE_PTHREADS
......
......@@ -550,18 +550,20 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
int nleft;
off_t offset;
off_t newpos;
bytes = TILE_WIDTH * TILE_HEIGHT * tile->bpp;
rbytes = tile_size (tile);
/* If there is already a valid swap_offset, use it */
if (tile->swap_offset == -1)
tile->swap_offset = tile_swap_find_offset (def_swap_file, fd, bytes);
newpos = tile_swap_find_offset (def_swap_file, fd, bytes);
else
newpos = tile->swap_offset;
if (def_swap_file->cur_position != tile->swap_offset)
if (def_swap_file->cur_position != newpos)
{
def_swap_file->cur_position = tile->swap_offset;
offset = lseek (fd, tile->swap_offset, SEEK_SET);
offset = lseek (fd, newpos, SEEK_SET);
if (offset == -1)
{
if (seek_err_msg)
......@@ -569,6 +571,7 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
seek_err_msg = FALSE;
return;
}
def_swap_file->cur_position = newpos;
}
nleft = rbytes;
......@@ -592,6 +595,7 @@ tile_swap_default_out (DefSwapFile *def_swap_file,
* tile->data is freed in tile_cache_zorch_next
*/
tile->dirty = FALSE;
tile->swap_offset = newpos;
write_err_msg = seek_err_msg = TRUE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment