Stale lockfile problem

Ralf Habacker ralf.habacker at freenet.de
Wed Jun 29 13:53:54 CEST 2005


Am Dienstag, 28. Juni 2005 22:13 schrieb Alessandro Fiorino:
> After installing cygwin I downloaded the kde-cygwin snapshot at
> http://webdev.cegit.de/snapshots/kde-cygwin/kde/kde3.4/ and followed
> the instruction, but when I try to start kde it goes in and endless
> loop with this error going on forever
> "WARNING: Problem deleting stale lockfile
> /opt/kde3.4/home/share/config/kconf_updaterc.lock"
> Any suggestion? I've already tried on two different PCs, both of them
> running Windows XP SP2

Are there access rights problems ? I'm using xp with sp1 without problems. You 
may download filemon from www.sysinternals.com to see what happens with the 
file or you may inspect the code segment below. It may be that there is a 
cygwin related stat problem. Perhaps you can write a testcase from the 
snippet below. 




static KLockFile::LockResult deleteStaleLock(const QString &lockFile, 
KDE_struct_stat &st_buf)
{
   // This is dangerous, we could be deleting a new lock instead of
   // the old stale one, let's be very careful
              
   // Create temp file
   KTempFile ktmpFile(lockFile);
   if (ktmpFile.status() != 0)
      return KLockFile::LockError;
              
   QCString lckFile = QFile::encodeName( lockFile );
   QCString tmpFile = QFile::encodeName(ktmpFile.name());
   ktmpFile.close();
   ktmpFile.unlink();
              
#ifdef Q_OS_UNIX
   // link to lock file
   if (::link(lckFile, tmpFile) != 0)
      return KLockFile::LockFail; // Try again later
#else
   //TODO for win32
   return KLockFile::LockOK;
#endif

   // check if link count increased with exactly one
   // and if the lock file still matches
   KDE_struct_stat st_buf1;
   KDE_struct_stat st_buf2;
   memcpy(&st_buf1, &st_buf, sizeof(KDE_struct_stat));
   st_buf1.st_nlink++;
   if ((KDE_lstat(tmpFile, &st_buf2) == 0) && statResultIsEqual(st_buf1, 
st_buf2))
   {
      if ((KDE_lstat(lckFile, &st_buf2) == 0) && statResultIsEqual(st_buf1, 
st_buf2))
      {
         // - - if yes, delete lock file, delete temp file, retry lock
         qWarning("WARNING: deleting stale lockfile %s", lckFile.data());
         ::unlink(lckFile);
         ::unlink(tmpFile);
         return KLockFile::LockOK;
      }
   }
   // Failed to delete stale lock file
   qWarning("WARNING: Problem deleting stale lockfile %s", lckFile.data());
   ::unlink(tmpFile);
   return KLockFile::LockFail;
}



you may download filemon and procexp from sysinternals.com to get some hints. 
Filemon shows you 


Ralf 


More information about the kde-cygwin mailing list