Branch: Tag:

2000-01-08

2000-01-08 20:43:43 by Martin Stjernholm <mast@lysator.liu.se>

Fix for the "Key does not exist!" bug in the image cache. Thanks to
Stefan Wallström.

Rev: server/base_server/roxen.pike:1.387

5:    */      // ABS and suicide systems contributed freely by Francesco Chemolli - constant cvs_version="$Id: roxen.pike,v 1.386 2000/01/08 11:04:05 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.387 2000/01/08 20:43:43 mast Exp $";      object backend_thread;   ArgCache argcache;
2303:    if( cache[ data ] )    return cache[ data ][ CACHE_SKEY ];    +  if( sizeof( cache ) >= CACHE_SIZE ) +  { +  array i = indices(cache); +  while( sizeof(cache) > CACHE_SIZE-CLEAN_SIZE ) { +  string idx=i[random(sizeof(i))]; +  if(arrayp(cache[idx])) { +  m_delete( cache, cache[idx][CACHE_SKEY] ); +  m_delete( cache, idx ); +  } +  else { +  m_delete( cache, cache[idx] ); +  m_delete( cache, idx ); +  } +  } +  } +     string id = create_key( data );    cache[ data ] = ({ 0, 0 });    cache[ data ][ CACHE_VALUE ] = copy_value( args );    cache[ data ][ CACHE_SKEY ] = id;    cache[ id ] = data; -  -  if( sizeof( cache ) > CACHE_SIZE ) -  { -  array i = indices(cache); -  while( sizeof(cache) > CACHE_SIZE-CLEAN_SIZE ) -  m_delete( cache, i[random(sizeof(i))] ); -  } +     return id;    }