Hello community,
here is the log from the commit of package libzypp
checked in at Thu Mar 27 22:17:27 CET 2008.
--------
--- libzypp/libzypp.changes 2008-03-24 21:18:55.000000000 +0100
+++ /mounts/work_src_done/STABLE/libzypp/libzypp.changes 2008-03-26 16:38:58.083393000 +0100
@@ -1,0 +2,9 @@
+Wed Mar 26 16:15:24 CET 2008 - ma@suse.de
+
+- Allow prioritizing repos by adding a line 'priority=N' to the
+ .repo file. Where N is an integer number from 1 (highest prio)
+ to 99 (least and default). (bnc #369827, fate #302872)
+- version 4.6.1
+- revision 9276
+
+-------------------------------------------------------------------
Old:
----
libzypp-4.6.0.tar.bz2
New:
----
libzypp-4.6.1.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libzypp.spec ++++++
--- /var/tmp/diff_new_pack.V10503/_old 2008-03-27 22:12:10.000000000 +0100
+++ /var/tmp/diff_new_pack.V10503/_new 2008-03-27 22:12:10.000000000 +0100
@@ -1,5 +1,5 @@
#
-# spec file for package libzypp (Version 4.6.0)
+# spec file for package libzypp (Version 4.6.1)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -17,9 +17,9 @@
BuildRoot: %{_tmppath}/%{name}-%{version}-build
AutoReqProv: on
Summary: Package, Patch, Pattern, and Product Management
-Version: 4.6.0
+Version: 4.6.1
Release: 1
-Source: libzypp-4.6.0.tar.bz2
+Source: libzypp-4.6.1.tar.bz2
Source1: libzypp-rpmlintrc
Prefix: /usr
Provides: yast2-packagemanager
@@ -62,7 +62,7 @@
Ladislav Slezak
%package devel
-Requires: libzypp == 4.6.0
+Requires: libzypp == 4.6.1
Requires: libxml2-devel curl-devel openssl-devel rpm-devel glibc-devel zlib-devel
Requires: bzip2 popt-devel dbus-1-devel glib2-devel hal-devel boost-devel libstdc++-devel
Requires: cmake libsatsolver-devel
@@ -156,6 +156,12 @@
%{_libdir}/pkgconfig/libzypp.pc
%changelog
+* Wed Mar 26 2008 ma@suse.de
+- Allow prioritizing repos by adding a line 'priority=N' to the
+ .repo file. Where N is an integer number from 1 (highest prio)
+ to 99 (least and default). (bnc #369827, fate #302872)
+- version 4.6.1
+- revision 9276
* Mon Mar 24 2008 coolo@suse.de
- support plaindir again (at least the most important parts)
* Fri Mar 21 2008 jreidinger@suse.cz
++++++ libzypp-4.6.0.tar.bz2 -> libzypp-4.6.1.tar.bz2 ++++++
++++ 5522 lines of diff (skipped)
++++ retrying with extended exclude list
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/devel/devel.ma/NewPool.cc new/libzypp-4.6.1/devel/devel.ma/NewPool.cc
--- old/libzypp-4.6.0/devel/devel.ma/NewPool.cc 2008-03-24 21:18:37.000000000 +0100
+++ new/libzypp-4.6.1/devel/devel.ma/NewPool.cc 2008-03-26 16:35:41.000000000 +0100
@@ -134,6 +134,25 @@
///////////////////////////////////////////////////////////////////
+std::ostream & testDump( std::ostream & str, const PoolItem & pi )
+{
+ str << pi << endl;
+ Package::constPtr p( asKind<Package>(pi) );
+ if ( p )
+ {
+#define OUTS(V) str << str::form("%-25s: ",#V) << p->V() << endl
+ OUTS( summary );
+ OUTS( size );
+ OUTS( downloadSize );
+ OUTS( sourcePkgName );
+ OUTS( sourcePkgEdition );
+ OUTS( checksum );
+ OUTS( location );
+#undef OUTS
+ }
+ return str;
+}
+
struct Xprint
{
bool operator()( const PoolItem & obj_r )
@@ -518,6 +537,7 @@
}
}
+ dumpRange( USR, satpool.reposBegin(), satpool.reposEnd() );
USR << "pool: " << pool << endl;
///////////////////////////////////////////////////////////////////
@@ -531,32 +551,38 @@
// printf ("datadir: %s\n", di.kv.str);
// }
- sat::LocaleSupport myLocale( Locale("de") );
+#if 0
+ const LocaleSet & avlocales( ResPool::instance().getAvailableLocales() );
- if ( myLocale.isAvailable() )
+ for_( it, avlocales.begin(), avlocales.end() )
{
- MIL << "Support for locale '" << myLocale.locale() << "' is available." << endl;
- }
- if ( ! myLocale.isRequested() )
- {
- MIL << "Will enable support for locale '" << myLocale.locale() << "'." << endl;
- myLocale.setRequested( true );
- }
- MIL << "Packages supporting locale '" << myLocale.locale() << "':" << endl;
- for_( it, myLocale.begin(), myLocale.end() )
- {
- // iterate over sat::Solvables
- MIL << " " << *it << endl;
- // or get the PoolItems
- DBG << " " << PoolItem(*it) << endl;
+ sat::LocaleSupport myLocale( *it );
+
+ if ( ! myLocale.isRequested() )
+ {
+ MIL << "Will enable support for locale '" << myLocale.locale() << "'." << endl;
+ myLocale.setRequested( true );
+ }
+ MIL << "Packages supporting locale '" << myLocale.locale() << "':" << endl;
+ for_( it, myLocale.begin(), myLocale.end() )
+ {
+ // iterate over sat::Solvables
+ // MIL << " " << *it << endl;
+
+ // or get the PoolItems
+ PoolItem pi(*it);
+ MIL << " " << pi << endl;
+ }
}
+
// for_( it, poolItemIterator(myLocale.begin()), poolItemIterator(myLocale.end()) )
// {
// iterate over PoolItem
// MIL << " " << *it << endl;
// }
+#endif
#if 0
@@ -620,6 +646,21 @@
}
+ PoolItem pi ( getPi<Package>("vim") );
+ MIL << pi << endl;
+ if ( pi )
+ {
+ testDump( MIL, pi );
+ }
+ getZYpp()->resolver()->addRequire( Capability("vim") );
+ solve();
+ vdumpPoolStats( USR << "Transacting:"<< endl,
+ make_filter_beginresfilter::ByTransact(pool),
+ make_filter_endresfilter::ByTransact(pool) ) << endl;
+
+
+
+
if ( 0 ) {
PoolItem pi ( getPi<Package>("amarok") );
MIL << pi << endl;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/package/libzypp.changes new/libzypp-4.6.1/package/libzypp.changes
--- old/libzypp-4.6.0/package/libzypp.changes 2008-03-24 21:18:35.000000000 +0100
+++ new/libzypp-4.6.1/package/libzypp.changes 2008-03-26 16:35:41.000000000 +0100
@@ -1,4 +1,13 @@
-------------------------------------------------------------------
+Wed Mar 26 16:15:24 CET 2008 - ma@suse.de
+
+- Allow prioritizing repos by adding a line 'priority=N' to the
+ .repo file. Where N is an integer number from 1 (highest prio)
+ to 99 (least and default). (bnc #369827, fate #302872)
+- version 4.6.1
+- revision 9276
+
+-------------------------------------------------------------------
Mon Mar 24 21:17:05 CET 2008 - coolo@suse.de
- support plaindir again (at least the most important parts)
Files old/libzypp-4.6.0/tests/repo/susetags/data/stable-x86-subset-gz/suse/setup/descr/kde-10.3-71.i586.pat.g and new/libzypp-4.6.1/tests/repo/susetags/data/stable-x86-subset-gz/suse/setup/descr/kde-10.3-71.i586.pat.g differ
Files old/libzypp-4.6.0/tests/repo/susetags/data/stable-x86-subset-gz/suse/setup/descr/kde-10.3-71.i586.pat.gz and new/libzypp-4.6.1/tests/repo/susetags/data/stable-x86-subset-gz/suse/setup/descr/kde-10.3-71.i586.pat.gz differ
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/tests/zypp/base/CMakeLists.txt new/libzypp-4.6.1/tests/zypp/base/CMakeLists.txt
--- old/libzypp-4.6.0/tests/zypp/base/CMakeLists.txt 2008-03-24 21:18:36.000000000 +0100
+++ new/libzypp-4.6.1/tests/zypp/base/CMakeLists.txt 2008-03-26 16:35:43.000000000 +0100
@@ -1,2 +1,3 @@
-ADD_TESTS(Sysconfig InterProcessMutex InterProcessMutex2)
+ADD_TESTS(Sysconfig )
+#ADD_TESTS( InterProcessMutex2 )
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/tests/zypp/base/InterProcessMutex2_test.cc new/libzypp-4.6.1/tests/zypp/base/InterProcessMutex2_test.cc
--- old/libzypp-4.6.0/tests/zypp/base/InterProcessMutex2_test.cc 2008-03-24 21:18:36.000000000 +0100
+++ new/libzypp-4.6.1/tests/zypp/base/InterProcessMutex2_test.cc 2008-03-26 16:35:43.000000000 +0100
@@ -46,16 +46,16 @@
MIL << "child, PID: " << getpid() << endl;
// child
sleep(3);
- BOOST_REQUIRE_THROW( InterProcessMutex("testcase", 0), ZYppLockedException);
+ BOOST_REQUIRE_THROW( InterProcessMutex( InterProcessMutex::Reader,"testcase", 0), ZYppLockedException);
//InterProcessMutex mutex2("testcase");
}
else
{
MIL << "parent: " << getpid() << endl;
- InterProcessMutex mutex("testcase");
+ InterProcessMutex mutex( InterProcessMutex::Writer, "testcase");
// parent
sleep(6);
- waitpid(r, &status, 0);
+ wait(NULL);
MIL << "first lock will go out of scope" << endl;
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/tests/zypp/base/InterProcessMutex_test.cc new/libzypp-4.6.1/tests/zypp/base/InterProcessMutex_test.cc
--- old/libzypp-4.6.0/tests/zypp/base/InterProcessMutex_test.cc 2008-03-24 21:18:36.000000000 +0100
+++ new/libzypp-4.6.1/tests/zypp/base/InterProcessMutex_test.cc 2008-03-26 16:35:43.000000000 +0100
@@ -48,12 +48,12 @@
// child
//BOOST_REQUIRE_THROW( InterProcessMutex("testcase"), ZYppLockedException);
sleep(3);
- InterProcessMutex mutex2("testcase");
+ InterProcessMutex mutex2(InterProcessMutex::Reader,"testcase");
}
else
{
MIL << "parent: " << getpid() << endl;
- InterProcessMutex mutex("testcase");
+ InterProcessMutex mutex(InterProcessMutex::Writer,"testcase");
// parent
sleep(3);
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/tests/zypp/data/Vendor/zypp2.conf new/libzypp-4.6.1/tests/zypp/data/Vendor/zypp2.conf
--- old/libzypp-4.6.0/tests/zypp/data/Vendor/zypp2.conf 2008-03-24 21:18:36.000000000 +0100
+++ new/libzypp-4.6.1/tests/zypp/data/Vendor/zypp2.conf 1970-01-01 01:00:00.000000000 +0100
@@ -1,127 +0,0 @@
-## Configuration file for software management
-## /etc/zypp/zypp.conf
-##
-## Boolean values are 0 1 yes no on off true false
-
-
-[main]
-
-
-##
-## Override the detected architecture
-##
-## Valid values: i586, i686, x86_64, ppc, ppc64, ia64, s390, s390x, ..
-## Default value: Autodetected
-##
-## ** CAUTION: Only set if you know what you're doing !
-## ** Changing this needs a full refresh (incl. download)
-## ** of all repository data.
-##
-# arch = s390
-
-
-##
-## Path where the repo metadata is downloaded and kept.
-##
-## Valid values: A directory
-## Default value: /var/cache/zypp/raw
-##
-## Changing this needs a full refresh (incl. download) of all repository data
-##
-# metadatadir = /var/cache/zypp/raw
-
-
-##
-## Path where the known repositories .repo files are kept
-##
-## Valid values: A directory
-## Default value: /etc/zypp/repos.d
-##
-## Changing this invalidates all known repositories
-##
-# reposdir = /etc/zypp/repos.d
-
-
-##
-## Path where the processed cache is kept (this is where zypp.db is located)
-##
-## Valid values: A directory
-## Default value: /var/cache/zypp
-##
-## Changing this needs a full refresh (except download) of all repository data
-##
-# cachedir = /var/cache/zypp
-
-
-##
-## Whether repository urls should be probed when added
-##
-## Valid values: boolean
-## Default value: false
-##
-## If true, accessability of repositories is checked immediately (when added)
-## (e.g. 'zypper ar' will check immediately)
-## If false, accessability of repositories is checked when refreshed
-## (e.g. 'zypper ar' will delay the check until the next refresh)
-##
-# repo.add.probe = false
-
-
-##
-## Amount of time in minutes that must pass before another refresh.
-##
-## Valid values: Integer
-## Default value: 10
-##
-## If you have autorefresh enabled for a repository, it is checked for
-## up-to-date metadata not more often than every
-## minutes. If an automatic request for refresh comes before
-## minutes passed since the last check, the request is ignored.
-##
-## A value of 0 means the repository will always be checked. To get the oposite
-## effect, disable autorefresh for your repositories.
-##
-## This option has no effect for repositories with autorefresh disabled, nor for
-## user-requested refresh.
-##
-# repo.refresh.delay = 10
-
-
-##
-## Whether to consider using a .patch.rpm when downloading a package
-##
-## Valid values: boolean
-## Default value: true
-##
-## Using a patch rpm will decrease the download size for package updates
-## since it does not contain all files of the package but only the changed
-## ones. The .patch.rpm is ready to be installed immediately after download.
-## There is no further processing needed, as it is for a .delta.rpm.
-##
-# download.use_patchrpm = true
-
-
-##
-## Whether to consider using a .delta.rpm when downloading a package
-##
-## Valid values: boolean
-## Default value: true
-##
-## Using a delta rpm will decrease the download size for package updates
-## since it does not contain all files of the package but only the binary
-## diff of changed ones. Recreating the rpm package on the local machine
-## is an expensive operation (memory,CPU). If your network connection is
-## not too slow, you benefit from disabling .delta.rpm.
-##
-# download.use_deltarpm = true
-
-
-##
-## Defining directory for equivalent vendors
-##
-## Valid values: A directory
-## Default value: /etc/zypp/vondors.d
-##
-#vendordir = ./../../tests/zypp/data/Vendor/vendors.d
-vendordir = /suse/coolo/prod/libzypp/tests/zypp/data/Vendor/vendors.d
-
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/VERSION.cmake new/libzypp-4.6.1/VERSION.cmake
--- old/libzypp-4.6.0/VERSION.cmake 2008-03-24 21:18:36.000000000 +0100
+++ new/libzypp-4.6.1/VERSION.cmake 2008-03-26 16:35:41.000000000 +0100
@@ -47,4 +47,4 @@
SET(LIBZYPP_MAJOR "4")
SET(LIBZYPP_MINOR "6")
SET(LIBZYPP_COMPATMINOR "6")
-SET(LIBZYPP_PATCH "0")
+SET(LIBZYPP_PATCH "1")
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/zypp/base/InterProcessMutex.cc new/libzypp-4.6.1/zypp/base/InterProcessMutex.cc
--- old/libzypp-4.6.0/zypp/base/InterProcessMutex.cc 2008-03-24 21:18:37.000000000 +0100
+++ new/libzypp-4.6.1/zypp/base/InterProcessMutex.cc 2008-03-26 16:35:41.000000000 +0100
@@ -25,9 +25,9 @@
namespace base
{
- ZYppLockedException::ZYppLockedException( const std::string & msg_r,
- const std::string &name,
- pid_t locker_pid )
+ZYppLockedException::ZYppLockedException( const std::string & msg_r,
+ const std::string &name,
+ pid_t locker_pid )
: Exception(msg_r)
, _locker_pid (locker_pid)
, _name(name)
@@ -37,127 +37,249 @@
{}
-InterProcessMutex::InterProcessMutex( const std::string &name,
+InterProcessMutex::InterProcessMutex( ConsumerType ctype,
+ const std::string &name,
int timeout )
- : _clean_lock(false)
- , _zypp_lockfile(0)
- , _locker_pid(0)
+ : _fd(0)
, _name(name)
, _timeout(timeout)
+ , _type(ctype)
{
// get the current pid
pid_t curr_pid = getpid();
Pathname lock_file = lockFilePath();
int totalslept = 0;
+ int k = 0;
while (1)
{
- if ( PathInfo(lock_file).isExist() )
+ k++;
+
+ // try to create the lock file atomically, this will fail if
+ // the lock exists
+ if ( ( _fd = open(lock_file.c_str(), O_WRONLY | O_CREAT | O_EXCL) ) == -1 )
{
- LMIL << "found lockfile " << lock_file << std::endl;
- openLockFile("r");
- shLockFile();
-
- pid_t locker_pid = lockerPid();
- pid_t curr_pid = getpid();
- LMIL << "Locker pid is " << locker_pid << " (our pid: " << curr_pid << ") "<< std::endl;
- _locker_pid = locker_pid;
- // if the same pid has the lock it means we are trying from a new
- // thread and we have to wait.
- // if it is a different one and it is running, then we have to wait
- // too, otherwise we can just take ownership of the lock
- bool locker_running = isProcessRunning(locker_pid);
- LMIL << "locker program is " << (locker_running ? "" : " not") << " running." << endl;
-
- // if the locker process runs and we are not root
- // we can give access without risk.
- if ( locker_running && ( geteuid() != 0 ) )
+ struct flock lock;
+
+ // the file exists, lets see if someone has it locked exclusively
+ if ( (_fd = open(lock_file.c_str(), O_RDONLY)) == -1 )
{
- LMIL << locker_pid << " is running and has a lock. Access as normal user allowed." << std::endl;
- break;
+ ZYPP_THROW(Exception(str::form(_("It %d, Can't open lock file: %s"), k, strerror(errno))));
}
- // if the locker process is not running we have different cases
- // if we are root, we can clean its lock file, and take ownership of
- // it, which may work or not depending on result of unlink.
- // if the process is not running, and we are not root, we are not able to
- // do much, so we are allowed to continue.
- else if ( ! locker_running )
+
+ memset(&lock, 0, sizeof(struct flock));
+ lock.l_whence = SEEK_SET;
+
+ // GETLK tells you the conflicting lock as if the lock you pass
+ // would have been set. So set the lock type depending on wether
+ // we are a writer or a reader.
+ lock.l_type = ( ( _type == Writer ) ? F_WRLCK : F_RDLCK );
+
+
+ // get lock information
+ if (fcntl(_fd, F_GETLK, &lock) < 0)
{
- if ( geteuid() == 0 )
- {
- LMIL << locker_pid
- <<" has a lock, but process is not running. Cleaning lock file."
- << std::endl;
+ close(_fd);
+ ZYPP_THROW(Exception(string("Error getting lock info: ") + strerror(errno)));
+ }
- if ( filesystem::unlink(lock_file) == 0 )
- {
- createLockFile();
- // now open it for reading
- openLockFile("r");
- shLockFile();
- break;
- }
- else
- {
- ERR << "can't clean lockfile. Sorry, can't create a new lock. Lock ["
- << _name << "] still locked."
- << std::endl;
- ZYPP_THROW(ZYppLockedException(
- _("Can't clean lockfile. Sorry, can't create a new lock. Zypp still locked."),
- _name, locker_pid));
- }
- }
- else
- {
- LMIL << locker_pid
- << " not running and has a lock. Access as normal user allowed."
- << std::endl;
+
+ MIL << lock_file << " : ";
+ switch ( lock.l_type )
+ {
+ case F_WRLCK:
+ MIL << " Write-Lock conflicts" << endl;
+ break;
+ case F_RDLCK:
+ MIL << " Read-Lock conflicts" << endl;
break;
- }
+ case F_UNLCK:
+ MIL << " No lock conflicts" << endl;
+ break;
+ default:
+ break;
+
}
- // if the locker process is running and we are root, we have to wait
- // or go away
- else /* if ( locker_running && ( geteuid() == 0 ) ) */
+
+ // F_GETLK is confusing
+ // http://groups.google.com/group/comp.unix.solaris/tree/browse_frm/month/2005-09/123fae2c774bceed?rnum=61&_done=%2Fgroup%2Fcomp.unix.solaris%2Fbrowse_frm%2Fmonth%2F2005-09%3F
+ // new table of access
+ // F_WRLCK Reader Wait or abort
+ // F_WRLCK Writer Wait or abort
+ // F_RDLCK Writer Wait or abort
+ // F_RDLCK Reader Can't happen, anyway, wait or abort
+ // F_UNLCK Reader Take reader lock
+ // F_UNLCK Writer Take writer lock
+
+
+
+ // wait or abort
+ if ( lock.l_type != F_UNLCK )
{
- LMIL << locker_pid << " is running and has a lock." << std::endl;
+ // some lock conflicts with us.
+ LMIL << "pid " << lock.l_pid << " is running and has a lock that conflicts with us." << std::endl;
// abort if we have slept more or equal than the timeout, but
// not for the case where timeout is negative which means no
// timeout and therefore we never abort.
if ( (totalslept >= _timeout) && (_timeout >= 0 ) )
+ {
+ close(_fd);
ZYPP_THROW(ZYppLockedException(
_("This action is being run by another program already."),
- _name, locker_pid));
+ _name, lock.l_pid));
+ }
// if not, let sleep one second and count it
LMIL << "waiting 1 second..." << endl;
- unLockFile();
- closeLockFile();
+ close(_fd);
sleep(1);
++totalslept;
continue;
}
+ else if ( ( lock.l_type == F_UNLCK ) && ( _type == Reader ) )
+ {
+ // either there is no lock or a reader has it so we just
+ // acquire a reader lock.
+ // TODO to know wether there is no lock over the file or there
+ // is a reader, we would need to test for a writer lock
+ // that conflicts with it.
+ //
+ // try to get more lock info
+ lock.l_type = F_WRLCK;
+
+ if (fcntl(_fd, F_GETLK, &lock) < 0)
+ {
+ close(_fd);
+ ZYPP_THROW(Exception(string("Error getting lock info: ") + strerror(errno)));
+ }
+
+ if ( lock.l_type == F_UNLCK )
+ {
+ LMIL << "no previous readers, unlinking lock file and retrying." << endl;
+
+ // actually there are no readers
+ // lets delete it and break, so the next loop will
+ // probably suceed in creating it. The worst thing that can
+ // happen is that another process will take it first, but
+ // we are not aiming at such level of correctness. Otherwise
+ // the code path will complicate too much.
+ memset(&lock, 0, sizeof(struct flock));
+ lock.l_type = F_WRLCK;
+ lock.l_whence = SEEK_SET;
+ lock.l_pid = getpid();
+
+ if (fcntl(_fd, F_SETLK, &lock) < 0)
+ {
+ close(_fd);
+ ZYPP_THROW (Exception( "Can't lock file to unlink it."));
+ }
+ filesystem::unlink(lock_file.c_str());
+ close(_fd);
+ continue;
+ }
+ else if ( lock.l_type == F_RDLCK )
+ {
+ // there is another reader.
+ LMIL << "previous readers on lock file. taking lock as a reader." << std::endl;
+ memset(&lock, 0, sizeof(struct flock));
+ lock.l_type = F_RDLCK;
+ lock.l_whence = SEEK_SET;
+ lock.l_pid = getpid();
+
+ if (fcntl(_fd, F_SETLK, &lock) < 0)
+ {
+ close(_fd);
+ ZYPP_THROW (Exception( "Can't lock file for reader"));
+ }
+ // and keep the lock open.
+ break;
+ }
+ else
+ {
+ // cant happen!
+ ERR << "impossible condition" << endl;
+
+ break;
+ }
+ }
+ else if ( ( lock.l_type == F_UNLCK ) && ( _type == Writer ) )
+ {
+ LMIL << "stale lock found" << endl;
+ // Nobody conflicts with a writer lock so nobody is actually
+ // locking.
+ // lets delete it and break, so the next loop will
+ // probably suceed in creating it. The worst thing that can
+ // happen is that another process will take it first, but
+ // we are not aiming at such level of correctness. Otherwise
+ // the code path will complicate too much.
+ memset(&lock, 0, sizeof(struct flock));
+ lock.l_type = F_WRLCK;
+ lock.l_whence = SEEK_SET;
+ lock.l_pid = getpid();
+
+ if (fcntl(_fd, F_SETLK, &lock) < 0)
+ {
+ close(_fd);
+ ZYPP_THROW (Exception( "Can't lock file to unlink it."));
+ }
+ filesystem::unlink(lock_file.c_str());
+ close(_fd);
+ continue;
+ }
+ else
+ {
+ // undefined case, just get out of the loop
+ LMIL << "undefined case!" << endl;
+
+ break;
+ }
+
}
- else
+ else
{
- MIL << "no lockfile " << lock_file << " found" << std::endl;
- if ( geteuid() == 0 )
+ // exclusive file creation succeeded. So may be we are the
+ // first writer or first reader
+
+ // try to lock it exclusively
+ // if it fails, someone won us, so we just go for another try
+ // or just abort
+ LMIL << "no lock found, taking ownership of it as a " << ( (_type == Reader ) ? "reader" : "writer" ) << endl;
+ struct flock lock;
+ memset(&lock, 0, sizeof(struct flock));
+ lock.l_whence = SEEK_SET;
+ lock.l_type = F_WRLCK;
+ lock.l_pid = getpid();
+
+ if (fcntl(_fd, F_SETLK, &lock) < 0)
{
- MIL << "running as root. Will attempt to create " << lock_file << std::endl;
- createLockFile();
- // now open it for reading
- openLockFile("r");
- shLockFile();
+ close(_fd);
+ ZYPP_THROW (Exception( "Can't lock file to write pid."));
}
- else
+
+ char buffer[100];
+ sprintf( buffer, "%d\n", curr_pid);
+ write( _fd, buffer, strlen(buffer));
+
+ // by now the pid is written and the file locked.
+ // If we are a reader, just downgrade the lock to
+ // read shared lock.
+ if ( _type == Reader )
{
- MIL << "running as user. Skipping creating " << lock_file << std::endl;
+ lock.l_type = F_RDLCK;
+
+ if (fcntl(_fd, F_SETLK, &lock) < 0)
+ {
+ close(_fd);
+ ZYPP_THROW (Exception( "Can't set lock file to shared"));
+ }
}
+
break;
- }
- break;
- }
+ }
+ } // end loop
+
MIL << "Finish constructor" << endl;
}
@@ -166,24 +288,23 @@
{
try
{
- pid_t curr_pid = getpid();
- if ( _zypp_lockfile )
+ Pathname lock_file = lockFilePath();
+ switch ( _type )
{
- Pathname lock_file = lockFilePath();
- unLockFile();
- closeLockFile();
-
- if ( _clean_lock )
- {
- MIL << "LOCK [" << _name << "] : cleaning lock file. (" << curr_pid << ")" << std::endl;
- if ( filesystem::unlink(lock_file) == 0 )
- MIL << "LOCK [" << _name << "] : lockfile cleaned. (" << curr_pid << ")" << std::endl;
- else
- ERR << "LOCK [" << _name << "] : cant clean lockfile. (" << curr_pid << ")" << std::endl;
- }
- }
- }
- catch(...) {} // let no exception escape.
+ case Reader:
+
+ break;
+
+ case Writer:
+ // we are the only writer, so unlink the file
+ filesystem::unlink(lock_file.c_str());
+ break;
+
+ }
+ // and finally close the file and release the lock
+ close(_fd);
+ }
+ catch(...) {} // let no exception escape.
}
@@ -192,69 +313,6 @@
return Pathname("/var/run/zypp-" + _name + ".pid");
}
-pid_t
-InterProcessMutex::locker_pid() const
-{
- return _locker_pid;
-}
-
-void InterProcessMutex::openLockFile(const char *mode)
-{
- Pathname lock_file = lockFilePath();
- _zypp_lockfile = fopen(lock_file.asString().c_str(), mode);
- if (_zypp_lockfile == 0)
- ZYPP_THROW (Exception( "Cant open " + lock_file.asString() + " in mode " + std::string(mode) ) );
-}
-
-void InterProcessMutex::closeLockFile()
-{
- fclose(_zypp_lockfile);
-}
-
-void InterProcessMutex::shLockFile()
-{
- int fd = fileno(_zypp_lockfile);
- int lock_error = flock(fd, LOCK_SH);
- if (lock_error != 0)
- ZYPP_THROW (Exception( "Cant get shared lock"));
- else
- XXX << "locked (shared)" << std::endl;
-}
-
-void InterProcessMutex::exLockFile()
-{
- int fd = fileno(_zypp_lockfile);
- // lock access to the file
- int lock_error = flock(fd, LOCK_EX);
- if (lock_error != 0)
- ZYPP_THROW (Exception( "Cant get exclusive lock" ));
- else
- XXX << "locked (exclusive)" << std::endl;
-}
-
-void InterProcessMutex::unLockFile()
-{
- int fd = fileno(_zypp_lockfile);
- // lock access to the file
- int lock_error = flock(fd, LOCK_UN);
- if (lock_error != 0)
- ZYPP_THROW (Exception( "Cant release lock" ));
- else
- XXX << "unlocked" << std::endl;
-}
-
-void InterProcessMutex::createLockFile()
-{
- pid_t curr_pid = getpid();
- openLockFile("w");
- exLockFile();
- fprintf(_zypp_lockfile, "%ld\n", (long) curr_pid);
- fflush(_zypp_lockfile);
- unLockFile();
- MIL << "written lockfile with pid " << curr_pid << std::endl;
- closeLockFile();
-}
-
bool InterProcessMutex::isProcessRunning(pid_t pid_r)
{
// it is another program, not me, see if it is still running
@@ -281,20 +339,6 @@
return still_running;
}
-pid_t InterProcessMutex::lockerPid()
-{
- pid_t locker_pid = 0;
- long readpid = 0;
-
- fscanf(_zypp_lockfile, "%ld", &readpid);
- locker_pid = (pid_t) readpid;
- return locker_pid;
-}
-
-bool InterProcessMutex::locked()
-{
- return true;
-}
}
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/zypp/base/InterProcessMutex.h new/libzypp-4.6.1/zypp/base/InterProcessMutex.h
--- old/libzypp-4.6.0/zypp/base/InterProcessMutex.h 2008-03-24 21:18:37.000000000 +0100
+++ new/libzypp-4.6.1/zypp/base/InterProcessMutex.h 2008-03-26 16:35:41.000000000 +0100
@@ -27,17 +27,32 @@
/**
+ *
* Inter process scoped lock implementation
*
- * This mutex will allow only one process to
+ * This mutex will allow only one writer process to
* reach a critical region protected by a mutex
- * of the same name.
+ * of the same name, if there are no readers
+ * at the same time.
+ *
+ * Multiple readers are allowed if there is no
+ * currently a writer.
*
*/
class InterProcessMutex
{
public:
/**
+ * Processes can be of two types
+ * Reader or Writer
+ */
+ enum ConsumerType
+ {
+ Reader,
+ Writer
+ };
+
+ /**
* Creates a mutex with a name and a timeout.
*
* default timeout is -1 which means no timeout
@@ -52,31 +67,23 @@
* the timeout is reached.
*
*/
- InterProcessMutex( const std::string &name = "zypp",
- int timeout = -1 );
-
+ InterProcessMutex( ConsumerType ctype,
+ const std::string &name = "zypp",
+ int timeout = -1 );
+
+ /**
+ * Destructor
+ */
~InterProcessMutex();
- pid_t locker_pid() const;
-
private:
- void openLockFile(const char *mode);
- void closeLockFile();
-
- void shLockFile();
- void exLockFile();
- void unLockFile();
- void createLockFile();
bool isProcessRunning(pid_t pid_r);
- pid_t lockerPid();
- bool locked();
Pathname lockFilePath() const;
private:
- bool _clean_lock;
- FILE *_zypp_lockfile;
- pid_t _locker_pid;
+ int _fd;
std::string _name;
int _timeout;
+ ConsumerType _type;
};
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/zypp/parser/RepoFileReader.cc new/libzypp-4.6.1/zypp/parser/RepoFileReader.cc
--- old/libzypp-4.6.0/zypp/parser/RepoFileReader.cc 2008-03-24 21:18:37.000000000 +0100
+++ new/libzypp-4.6.1/zypp/parser/RepoFileReader.cc 2008-03-26 16:35:41.000000000 +0100
@@ -11,6 +11,7 @@
*/
#include <iostream>
#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
#include "zypp/base/InputStream.h"
#include "zypp/base/UserRequestException.h"
@@ -42,10 +43,10 @@
++its )
{
MIL << (*its) << endl;
-
+
RepoInfo info;
info.setAlias(*its);
-
+
for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
it != dict.entriesEnd(*its);
++it )
@@ -54,7 +55,9 @@
if (it->first == "name" )
info.setName(it-> second);
else if ( it->first == "enabled" )
- info.setEnabled( it->second == "1" );
+ info.setEnabled( str::strToTrue( it->second ) );
+ else if ( it->first == "priority" )
+ info.setPriority( str::strtonum<unsigned>( it->second ) );
else if ( it->first == "baseurl" && !it->second.empty())
info.addBaseUrl( Url(it->second) );
else if ( it->first == "path" )
@@ -62,15 +65,15 @@
else if ( it->first == "type" )
info.setType(repo::RepoType(it->second));
else if ( it->first == "autorefresh" )
- info.setAutorefresh( it->second == "1" );
+ info.setAutorefresh( str::strToTrue( it->second ) );
else if ( it->first == "mirrorlist" && !it->second.empty())
info.setMirrorListUrl(Url(it->second));
else if ( it->first == "gpgkey" && !it->second.empty())
info.setGpgKeyUrl( Url(it->second) );
else if ( it->first == "gpgcheck" )
- info.setGpgCheck( it->second == "1" );
+ info.setGpgCheck( str::strToTrue( it->second ) );
else if ( it->first == "keeppackages" )
- info.setKeepPackages( it->second == "1" );
+ info.setKeepPackages( str::strToTrue( it->second ) );
else
ERR << "Unknown attribute " << it->second << " ignored" << endl;
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/zypp/RepoInfo.cc new/libzypp-4.6.1/zypp/RepoInfo.cc
--- old/libzypp-4.6.0/zypp/RepoInfo.cc 2008-03-24 21:18:37.000000000 +0100
+++ new/libzypp-4.6.1/zypp/RepoInfo.cc 2008-03-26 16:35:41.000000000 +0100
@@ -12,6 +12,7 @@
#include <iostream>
#include "zypp/base/Logger.h"
+#include "zypp/base/DefaultIntegral.h"
#include "zypp/RepoInfo.h"
@@ -42,6 +43,9 @@
//MIL << std::endl;
}
public:
+ static const unsigned defaultPriority = 99;
+
+ public:
bool enabled;
bool autorefresh;
bool gpgcheck;
@@ -57,6 +61,7 @@
Pathname filepath;
Pathname metadatapath;
Pathname packagespath;
+ DefaultIntegral priority;
public:
private:
@@ -98,6 +103,17 @@
//MIL << std::endl;
}
+ unsigned RepoInfo::priority() const
+ { return _pimpl->priority; }
+ unsigned RepoInfo::defaultPriority()
+ { return Impl::defaultPriority; }
+ RepoInfo & RepoInfo::setPriority( unsigned newval_r )
+ {
+ _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority;
+ return *this;
+ }
+
+
RepoInfo & RepoInfo::setEnabled( bool enabled )
{
_pimpl->enabled = enabled;
@@ -298,11 +314,12 @@
str << "- path : " << path() << std::endl;
str << "- type : " << type() << std::endl;
str << "- enabled : " << enabled() << std::endl;
+ str << "- priority : " << priority() << std::endl;
str << "- autorefresh : " << autorefresh() << std::endl;
- str << "- gpgcheck : " << gpgCheck() << std::endl;
- str << "- gpgkey : " << gpgKeyUrl() << std::endl;
- str << "- keeppackages : " << keepPackages() << std::endl;
+ str << "- gpgcheck : " << gpgCheck() << std::endl;
+ str << "- gpgkey : " << gpgKeyUrl() << std::endl;
+ str << "- keeppackages: " << keepPackages() << std::endl;
return str;
}
@@ -330,11 +347,15 @@
str << "type=" << type().asString() << endl;
str << "enabled=" << (enabled() ? "1" : "0") << endl;
+
+ if ( priority() != defaultPriority() )
+ str << "priority=" << priority() << endl;
+
str << "autorefresh=" << (autorefresh() ? "1" : "0") << endl;
str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
if ( ! (gpgKeyUrl().asString().empty()) )
str << "gpgkey=" <http://software.opensuse.org/openSUSE-Build-Service.asc
* enabled=1
+ * priority=10
* \endcode
*
* \note A RepoInfo is a hint about how
@@ -66,6 +67,9 @@
friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
public:
+ static unsigned defaultPrioity();
+
+ public:
RepoInfo();
~RepoInfo();
@@ -84,6 +88,22 @@
std::string escaped_alias() const;
/**
+ * Repository priority for solver.
+ * Some number between \c 1 (highest priority) and \c 99 (\ref defaultPriority).
+ */
+ unsigned priority() const;
+ /**
+ * The default priority (\c 99).
+ */
+ static unsigned defaultPriority();
+ /**
+ * Set repository priority for solver.
+ * A \c newval_r of \c 0 sets the default priority.
+ * \see \ref priority.
+ */
+ RepoInfo & setPriority( unsigned newval_r );
+
+ /**
* A Url under which the metadata are located, or a set of mirrors.
*
* This can't be empty in order the repository to be valid
@@ -218,6 +238,7 @@
*/
bool keepPackages() const;
+ public:
/**
* Add a base url. \see baseUrls
* \param url The base url for the repository.
@@ -322,11 +343,11 @@
*
*/
RepoInfo & setGpgKeyUrl( const Url &gpgkey );
-
+
/**
* \short Set if the packaqes downloaded from this repository will be kept in local cache
*
- * If the setting is true, all downloaded packages from this repository will be
+ * If the setting is true, all downloaded packages from this repository will be
* copied to the local raw cache.
*
* \param keep true (keep the downloaded packages) or false (delete them after installation)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/libzypp-4.6.0/zypp/Repository.cc new/libzypp-4.6.1/zypp/Repository.cc
--- old/libzypp-4.6.0/zypp/Repository.cc 2008-03-24 21:18:37.000000000 +0100
+++ new/libzypp-4.6.1/zypp/Repository.cc 2008-03-26 16:35:41.000000000 +0100
@@ -105,6 +105,10 @@
info_r.alias().c_str(), name().c_str() ) ) );
}
myPool().setRepoInfo( _repo, info_r );
+
+ // satsolver priority is based on '<', while yum's repoinfo
+ // uses 1(highest)->99(lowest). Thus we use -info_r.priority.
+ _repo->priority = -info_r.priority();
}
void Repository::clearInfo()
@@ -156,10 +160,8 @@
return str << "sat::repo(" << obj.name() << ")"
<< "{"
- << obj.solvablesSize()
- << ' ' << obj.get()->start << ' ' << obj.get()->end << ' '
- << (obj.get()->start < 0 ? "_START_":"")
- << (obj.get()->nsolvables < 0 ?"_NUMSOLV_":"")
+ << "prio " << obj.get()->priority
+ << ", size " << obj.solvablesSize()
<<"}";
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org