Fix dumb bug I introduced when allowing the arch to be set from
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 18 May 2006 15:17:45 +0000 (15:17 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 18 May 2006 15:17:45 +0000 (15:17 +0000)
a env variable.

zypp/ZYppFactory.cc
zypp/zypp_detail/ZYppImpl.cc

index fa1e58e..27afee8 100644 (file)
@@ -172,11 +172,12 @@ namespace zypp
 
     pid_t lockerPid()
     {
+      pid_t curr_pid = getpid();
       pid_t locked_pid = 0;
       long readpid = 0;
 
       fscanf(_zypp_lockfile, "%ld", &readpid);
-      MIL << "read: Lockfile " << ZYPP_LOCK_FILE << " has pid " << readpid << std::endl;
+      MIL << "read: Lockfile " << ZYPP_LOCK_FILE << " has pid " << readpid << " (our pid: " << curr_pid << ") "<< std::endl;
       locked_pid = (pid_t) readpid;
       return locked_pid;
     }
@@ -190,6 +191,7 @@ namespace zypp
 
       if ( lockFileExists() )
       {
+        MIL << "found lockfile " << lock_file << std::endl;
         openLockFile("r");
         shLockFile();
 
@@ -245,13 +247,19 @@ namespace zypp
       }
       else
       {
+        MIL << "no lockfile " << lock_file << " found" << std::endl;
         if ( geteuid() == 0 )
         {
+          MIL << "running as root. Will attempt to create " << lock_file << std::endl;
           createLockFile();
         // now open it for reading
           openLockFile("r");
           shLockFile();
         }
+        else
+        {
+          MIL << "running as user. Skipping creating " << lock_file << std::endl;
+        }
         return false;
       }
       return true;
index ed7e77d..327cdd1 100644 (file)
@@ -126,11 +126,21 @@ namespace zypp
       }
     
 
-      std::string fakearch(getenv("ZYPP_TESTSUITE_FAKE_ARCH"));
-      if ( fakearch.size() > 0 ) 
+      
+      if ( getenv("ZYPP_TESTSUITE_FAKE_ARCH") ) 
       {
-        _architecture = Arch( fakearch );
-        MIL << "ZYPP_TESTSUITE_FAKE_ARCH: Setting fake system architecture for test purpuses (warning! commit will be disabled!) to: '" << _architecture << "'" << endl;
+        Arch already_set = _architecture;
+        
+        std::string fakearch(getenv("ZYPP_TESTSUITE_FAKE_ARCH"));
+        try
+        { 
+          _architecture = Arch( fakearch );
+          MIL << "ZYPP_TESTSUITE_FAKE_ARCH: Setting fake system architecture for test purpuses (warning! commit will be disabled!) to: '" << _architecture << "'" << endl;
+        }
+        catch(...)
+        {
+          ERR << "ZYPP_TESTSUITE_FAKE_ARCH: Wrong architecture specified on env variable, using: '" << _architecture << "'" << endl;
+        }
       }
     }