Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (34a7a2b57a08be70f057d8a61a4f1712a5477b7f)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (34a7a2b57a08be70f057d8a61a4f1712a5477b7f)
  • Date: Thu, 17 Jan 2008 16:01:06 -0600

GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx AT sourcemage.org>:

ChangeLog | 10 ++++++
etc/sorcery/config | 2 -
var/lib/sorcery/modules/libdepends | 19 +++++++++++--
var/lib/sorcery/modules/libgrimoire | 2 -
var/lib/sorcery/modules/liblock | 52
++++++++++++------------------------
5 files changed, 47 insertions(+), 38 deletions(-)

New commits:
commit 34a7a2b57a08be70f057d8a61a4f1712a5477b7f
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

check if the lockdir and lockfile exist before trying to create them
(cherry picked from commit 7310ed273a5f3907fb5021dd8826c275c3d17996)
(cherry picked from commit 43567dfaad8754b2e4da8b8105339d3405a92f73)
(cherry picked from commit d5025a0f71cc77921d70393ca347235cf927d5ae)

commit 22d1f261cc742c1fc3341c56cc4adfa570abcb12
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

liblock: cleaned/clarified an old comment
(cherry picked from commit 1434ceb5ee4c2e69ea8e939b379623db249ee1aa)
(cherry picked from commit f0c0a568e835a9887ff430e25d0fbfce3b826baa)
(cherry picked from commit fd7f6768a8103b83e3b67ed7bb4f3da3e14021de)

commit 5e3dc9443fffd7501bc759131eb348f629ecd75a
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

MAX_SLEEP=3
(cherry picked from commit 3c4e9e7dd051fe52ffb22e48de271a64809677bf)
(cherry picked from commit 5a2a4cf17fd8478706927257f769006c12c58218)

commit 2360f8e8a9eb6178489d0cc2f03ad2815f0191a7
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

liblock: lock_resources can only work on one resource at a time, so
simplify its callers for clarity and a small speedup
(cherry picked from commit cb4246349af03e1309151d078a022bc14008a47d)

commit 1d0b5f4f369b2645ebd7bcc49a7c502a9082865b
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libgrimoire: 100% speedup of private_installed_version; unfortunately
speeding the lookup is not enough to counteract the needed locking
calls,
the function would get too slow
(cherry picked from commit c03eb8399e940bdf8bd17ffbcb2b280c6d61ba1c)

commit 0a4aa12bb2e8c8522a6cb44adccf33907d24b7b5
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libdepends: added more locking calls #7917

diff --git a/ChangeLog b/ChangeLog
index 18f2789..f6d7759 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-01-16 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libdepends: added more locking calls #7917
+ * libgrimoire: 100% speedup of private_installed_version;
unfortunately
+ speeding the lookup is not enough to counteract the needed locking
calls,
+ the function would get too slow
+ * liblock: lock_resources can only work on one resource at a time, so
+ simplify its callers for clarity and a small speedup
+ check if the lockdir and lockfile exist before trying to create them
+ * config: changed MAX_SLEEP to 2s
+
2008-01-15 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libstate: added use of locks (when reading files) and transactions
(when
modifying them) to the remaining functions. Part of #7917 that
diff --git a/etc/sorcery/config b/etc/sorcery/config
index c17a661..9025684 100755
--- a/etc/sorcery/config
+++ b/etc/sorcery/config
@@ -134,7 +134,7 @@ GRIMOIRE_MANIFEST_ALGORITHM=sha1

LOCK_DIR=/tmp/liblock-$UID
LOCK_TRANSACTIONS="$LOCK_DIR/liblock.locklist"
- MAX_SLEEP=5
+ MAX_SLEEP=3

TABLET_MAX_VERSION=1

diff --git a/var/lib/sorcery/modules/libdepends
b/var/lib/sorcery/modules/libdepends
index d0e11b6..9da13d4 100755
--- a/var/lib/sorcery/modules/libdepends
+++ b/var/lib/sorcery/modules/libdepends
@@ -293,6 +293,8 @@ function compute_installed_depends() {

# From here forward $1 and $2 are only used to refer to awk variables

+ lock_file "$DEPENDS_STATUS"
+ lock_file "$SPELL_STATUS"
# sub(/(.*)/, "", $2) removes a provider name
eval $(awk -v pattern="$pattern" -v status="$status" -F : 'BEGIN {
while (getline < ARGV[1] ) {
@@ -307,6 +309,8 @@ function compute_installed_depends() {
}
}
}' $DEPENDS_STATUS $SPELL_STATUS )
+ unlock_file "$DEPENDS_STATUS"
+ unlock_file "$SPELL_STATUS"
}

#---------------------------------------------------------------------
@@ -331,6 +335,8 @@ function compute_reverse_installed_depends() {

# From here forward $1 and $2 are only used to refer to awk variables

+ lock_file "$DEPENDS_STATUS"
+ lock_file "$SPELL_STATUS"
# sub(/(.*)/, "", $2) removes a provider name
eval $(awk -v pattern="$pattern" -v status="$status" -F : 'BEGIN {
while (getline < ARGV[1] ) {
@@ -345,6 +351,8 @@ function compute_reverse_installed_depends() {
}
}
}' $DEPENDS_STATUS $SPELL_STATUS )
+ unlock_file "$DEPENDS_STATUS"
+ unlock_file "$SPELL_STATUS"
}

#---------------------------------------------------------------------
@@ -440,7 +448,6 @@ function private_run_depends()
local base_deps
base_deps=$(search_depends_status $DEPENDS_STATUS basesystem|cut -f2 -d:)

-
# We only need to run the stuff if we are going to be casting.
# It only needs to be added to the casting hash table if we are
# really casting it
@@ -459,7 +466,11 @@ function private_run_depends()
rm -f $DEPENDS_CONFIG/$SPELL
test -f $DEPENDS_CONFIG/$SPELL.p &&
mkdir -p $ABANDONED_PERSIST &&
- mv -f $DEPENDS_CONFIG/$SPELL.p $ABANDONED_PERSIST/$SPELL.p
+ local t_spell_p=$(lock_start_transaction "$DEPENDS_CONFIG/$SPELL.p") &&
+ local t_abandonded_p=$(lock_start_transaction
"$ABANDONED_PERSIST/$SPELL.p") &&
+ mv -f "$t_spell_p" "$t_abandonded_p" &&
+ lock_commit_transaction "$DEPENDS_CONFIG/$SPELL.p" &&
+ lock_commit_transaction "$ABANDONED_PERSIST/$SPELL.p"
fi
prepare_spell_config
SCRIPT_DIRECTORY=`codex_find_spell_by_name $SPELL`
@@ -549,7 +560,9 @@ function private_upward_depends() {
# Note, use the reverse depends tree for this when we get a chance
# and/or move the weird pattern into library functions...
# (afrayedknot 2005-10-02)
+ lock_file "$DEPENDS_STATUS"
tmp=$(grep "^.*:$1\(([^:]*)\)\?" $DEPENDS_STATUS|cut -f1 -d:|tr "\n" " ")
+ unlock_file "$DEPENDS_STATUS"
local j k each
let j=${#NEW_UP_DEPENDS[*]}
for each in $tmp; do
@@ -1585,9 +1598,11 @@ function real_show_up_depends()
hash_reset done
compute_reverse_installed_depends foo
if [[ "$type" == "verbose" ]] ; then
+ lock_file "$DEPENDS_STATUS"
show_up_depends_sub "$1"|while read line; do
grep "$line" "$DEPENDS_STATUS"
done
+ unlock_file "$DEPENDS_STATUS"
else
show_up_depends_sub "$1"|cut -f1 -d:
fi|sort|uniq
diff --git a/var/lib/sorcery/modules/libgrimoire
b/var/lib/sorcery/modules/libgrimoire
index ab3a635..afe1898 100755
--- a/var/lib/sorcery/modules/libgrimoire
+++ b/var/lib/sorcery/modules/libgrimoire
@@ -204,7 +204,7 @@ function real_installed_version() {
##
#---------------------------------------------------------------------
function private_installed_version() {
- grep "^$1:" $SPELL_STATUS | cut -d : -f4 | head -n 1
+ awk -F : '/^'$1':/ {print $4; exit}' $SPELL_STATUS
}

#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/liblock b/var/lib/sorcery/modules/liblock
index ad73bc5..3ed8767 100755
--- a/var/lib/sorcery/modules/liblock
+++ b/var/lib/sorcery/modules/liblock
@@ -16,9 +16,7 @@
## /etc/sorcery/config
#-----------------------

-# global options that can be changed to suit your needs.
-#Perhaps this should be moved to the config? (Duff, 04/07)
-
+# global options for external users; sorcery defines these in its own config
[ -z "$LOCK_DIR" ] && LOCK_DIR=/tmp/lockdir
[ -z "$MAX_SLEEP" ] && MAX_SLEEP=2

@@ -79,9 +77,9 @@ trylock_resources()

debug "trylock_resources" "lockfile=${lockfile}"

- mkdir -p "${LOCK_DIR}"
+ [[ -d $LOCK_DIR ]] || mkdir -p "$LOCK_DIR"

- if ! mkdir "${lockfile}" 2>/dev/null; then
+ if [[ -d ${lockfile} ]] || ! mkdir "${lockfile}" 2>/dev/null; then
# we try to remove stale locks here and try again
sleep 0.1
global_clean_resources
@@ -214,12 +212,7 @@ global_clean_resources()
function lock_file()
{
debug "liblock" "$FUNCNAME - $*"
- local FILE
- lock_resources $(
- for FILE in "$@" ; do
- echo file $FILE
- done
- )
+ lock_resources file "$1"
}


@@ -233,12 +226,7 @@ function lock_file()
function unlock_file()
{
debug "liblock" "$FUNCNAME - $*"
- local FILE
- unlock_resources $(
- for FILE in "$@" ; do
- echo file $FILE
- done
- )
+ unlock_resources file "$1"
}

#---------------------------------------------------------------------
@@ -260,31 +248,27 @@ function unlock_file()
function lock_start_transaction()
{
debug "liblock" "$FUNCNAME - $*"
- local i TRANSNAME NUMTRANS RET=""
+ local NUMTRANS file="$1"

- if lock_file "$@" ; then
+ if lock_file "$file" ; then

lock_file $LOCK_TRANSACTIONS
[ -s $LOCK_TRANSACTIONS ] || echo "0:::" > $LOCK_TRANSACTIONS

NUMTRANS=`tail -n 1 $LOCK_TRANSACTIONS | cut -d : -f 1`
- NUMTRANS=${NUMTRANS:-1}
- RET=()
-
- for i in $* ; do
- let NUMTRANS++
- # cp file to temp file, if doesn't exist, create empty file.
- if [ -e "$i" ] ; then
- cp "$i" "$LOCK_TRANSACTIONS.$NUMTRANS"
- else
- echo -n "" > $LOCK_TRANSACTIONS.$NUMTRANS
- fi
- echo "$NUMTRANS:$i:$$" >$LOCK_TRANSACTIONS
- RET[$NUMTRANS]="${LOCK_TRANSACTIONS}.${NUMTRANS}"
- done
+ NUMTRANS=${NUMTRANS:-1} # TODO: check if this should fallback to 0
+
+ let NUMTRANS++
+ # cp file to temp file or if doesn't exist, create an empty file.
+ if [[ -e $file ]]; then
+ cp "$file" "$LOCK_TRANSACTIONS.$NUMTRANS"
+ else
+ echo -n "" > $LOCK_TRANSACTIONS.$NUMTRANS
+ fi
+ echo "$NUMTRANS:$file:$$" >$LOCK_TRANSACTIONS

unlock_file $LOCK_TRANSACTIONS
- echo ${RET[*]}
+ echo "$LOCK_TRANSACTIONS.$NUMTRANS"
return 0

else




Archive powered by MHonArc 2.6.24.

Top of Page