Beispiel #1
0
bool cleanup()
  {
  bool res = false;

  Client *p;
  ringloop(client_root,p)
    if( p->alive() && p->checklocks() )
      res = true;
  Lock *nextlp = NULL; // initialized just to avoid compiler warnings
  for( Lock *lp = hanging_lock_root.next(); lp != &hanging_lock_root; 
	lp = nextlp)
    {
    nextlp = lp->next();
    if( !lp->active() )
      {
      delete lp;
      res = true;
      }
    else if( lp->expired() )
      {
      // if connection with client is already broken a for a long time
      // and lock is still here, than client probably have forgotten
      // to drop it. So we do it ourselves.
      // But we may have problems if client is still alive and will try
      // to do unlock. Than shared memory will be corrupted.
      lp->force_unlock();
      delete lp;
      res = true;
      }
    }
  Info* nextip = NULL; // initialized just to avoid compiler warnings
  for(Info *ip = info_root.next(); ip->is_real(); ip = nextip )
    {
    nextip = ip->next();
    if( ip->may_be_dropped() )
      {
      delete ip;
      res = true;
      }
    }
  return res;
  }