Skip to Content.
Sympa Menu

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

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 (279988997c0ab5fd0a96f7b437f00296ec6f2110)
  • Date: Tue, 15 Jan 2008 06:13:58 -0600

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

ChangeLog | 7 ++
var/lib/sorcery/modules/build_api/common | 18 +++---
var/lib/sorcery/modules/libresurrect | 4 -
var/lib/sorcery/modules/libstate | 84
+++++++++++++++++++++++--------
4 files changed, 81 insertions(+), 32 deletions(-)

New commits:
commit 279988997c0ab5fd0a96f7b437f00296ec6f2110
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

Revert "moved over from the previous repo: changelog printing
customization"
1.15 material
This reverts commit a664cba6560bf60e17c8ab98e4186913d9aadeb9.

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

changelog entry for the last few commits
(cherry picked from commit 3b90ae0e7a048a764971fa94b494cf71f47d5aac)

commit 1534097a5ebd3096c2ea82223477908f4aa0ce99
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libressurect: fix a now bad locking call
(cherry picked from commit c8bac682174aefe315eb32f81e8c28e11a716383)

commit 2c6b3949dfe68c7ef8c7cfaaa6d28a7668f90fce
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

common: removed two "new" wrong locks
(cherry picked from commit ff1944760ad070d4186f5f7d87d2fbe5303b567b)

commit 1811339c403d32d65f2927071af43d44665f1d31
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

common: remove EOL whitespace
(cherry picked from commit 1ba309e90a88b28a26d1432fee7cc5712d34b80c)

commit 020f45f576e256c81cbba72089334396d4562f31
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

use locking in the rest of libstate (=everywhere)
(cherry picked from commit a14b4e055dbf59ff5af4b2efdc787e24a56b5861)

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

moved over from the previous repo: changelog printing customization
(cherry picked from commit 387ac9304221e65b443f5ce5d75de2aca49bdec4)
(cherry picked from commit bc8ecce21bd90ddfcb06d39a1b445fda28a0bd8a)

diff --git a/ChangeLog b/ChangeLog
index 4133aee..323ea22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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
+ hopefully fixes the annoying #13345
+ * build_api/common: accompanying changes to avoid double locking
+ * libressurect: accompanying changes to avoid double locking
+
2007-12-31 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* liblock: avoid two possible tiny race conditions

diff --git a/var/lib/sorcery/modules/build_api/common
b/var/lib/sorcery/modules/build_api/common
index 5086c03..4e1f7e8 100755
--- a/var/lib/sorcery/modules/build_api/common
+++ b/var/lib/sorcery/modules/build_api/common
@@ -111,7 +111,7 @@ function run_config_loc () {
## If the spell is not installed (or held) the spell is not dispelled.
##
#---------------------------------------------------------------------
-function real_prepare_install() { (
+function real_prepare_install() { (

debug "libgrimoire" "Running prepare_install() on $SPELL"

@@ -135,9 +135,9 @@ save_bin_lib_paths
}

#--------------------------------------------------------------------
-##
+##
## append old libraries and binaries to the appropriate environmental
-## variables so that they can be found by sorcery if they get
+## variables so that they can be found by sorcery if they get
## dispelled
##
#--------------------------------------------------------------------
@@ -246,10 +246,10 @@ function run_spell_success() {
# update depends info
debug "build_api/common" "Merging depends info"

- local t_DEPENDS_STATUS=$(lock_start_transaction $DEPENDS_STATUS)
# none of the old values are valid, only the new, uncommitted values are
- remove_depends_status $t_DEPENDS_STATUS $SPELL
+ remove_depends_status $DEPENDS_STATUS $SPELL
local spell_depends spell_sub_depends spell_rsub_depends
+ local t_DEPENDS_STATUS=$(lock_start_transaction $DEPENDS_STATUS)
get_uncommitted_depends_file $SPELL spell_depends
if [ -e "$spell_depends" ] ; then
cat $spell_depends >> $t_DEPENDS_STATUS
@@ -261,10 +261,10 @@ function run_spell_success() {
test -e "$ABANDONED_DEPENDS/$SPELL" &&
rm -f $ABANDONED_DEPENDS/$SPELL &>/dev/null

- local t_SUB_DEPENDS_STATUS=$(lock_start_transaction $SUB_DEPENDS_STATUS)
# none of the old values are valid, only the new, uncommitted values are
- remove_sub_depends $t_SUB_DEPENDS_STATUS "" "$SPELL"
+ remove_sub_depends $SUB_DEPENDS_STATUS "" "$SPELL"
local spell_sub_depends
+ local t_SUB_DEPENDS_STATUS=$(lock_start_transaction $SUB_DEPENDS_STATUS)
get_uncommitted_sub_depends_file $SPELL spell_sub_depends
if [ -e "$spell_sub_depends" ] ; then
cat $spell_sub_depends >> $t_SUB_DEPENDS_STATUS
@@ -371,9 +371,9 @@ function run_spell_failure() {
get_uncommitted_rsub_depends_file $SPELL spell_rsub_depends
rm -f "$spell_sub_depends" "$spell_rsub_depends"

- if [[ $CLEAN_SOURCE == on ]]
+ if [[ $CLEAN_SOURCE == on ]]
then
- rm_source_dir
+ rm_source_dir
if [[ $STAGED_INSTALL != off ]]
then
destroy_stage_root
diff --git a/var/lib/sorcery/modules/libresurrect
b/var/lib/sorcery/modules/libresurrect
index c93c4a9..54fdeeb 100755
--- a/var/lib/sorcery/modules/libresurrect
+++ b/var/lib/sorcery/modules/libresurrect
@@ -572,10 +572,10 @@ function resurrect_success() {
# 15) commit state data:
if [[ $OLD_TABLET_DIR ]] ; then
# depends info if it exists
- local t_DEPENDS_STATUS=$(lock_start_transaction "$DEPENDS_STATUS")
# none of the old values are valid, only the new, uncommitted values are
- remove_depends_status $t_DEPENDS_STATUS $SPELL
+ remove_depends_status $DEPENDS_STATUS $SPELL
local spell_depends=$OLD_TABLET_DIR/depends
+ local t_DEPENDS_STATUS=$(lock_start_transaction "$DEPENDS_STATUS")
if [ -e $spell_depends ] ; then
cat $spell_depends >> $t_DEPENDS_STATUS
fi
diff --git a/var/lib/sorcery/modules/libstate
b/var/lib/sorcery/modules/libstate
index 97f1e6c..5e7d7ef 100755
--- a/var/lib/sorcery/modules/libstate
+++ b/var/lib/sorcery/modules/libstate
@@ -45,7 +45,9 @@ function add_depends()
return 1
fi

- echo "$1:$2:$3:$4:$5:$6" >> $depends_status
+ local t_status=$(lock_start_transaction "$depends_status")
+ echo "$1:$2:$3:$4:$5:$6" >> "$t_status"
+ lock_commit_transaction "$depends_status"

return 0

@@ -67,6 +69,10 @@ function add_depends()
## @param on arg
## @param off arg
##
+## @return 0 if entry was found
+## @return 1 if entry was not found
+## @return 2 on error
+##
#---------------------------------------------------------------------
function search_depends_status_exact()
{ # $1=depends file $2=spell, $3=depends, $4=on/off, $5=optional/required,
$6=on arg, $7=off arg
@@ -77,8 +83,13 @@ function search_depends_status_exact()
local a1 a2 a3 a4 a5 a6
a1=`esc_str "$1"` ; a2=`esc_str "$2"` ; a3=`esc_str "$3"` ; a4=`esc_str
"$4"`; a5=`esc_str "$5"`; a6=`esc_str "$6"`
debug "libstate" "search_depends_status_exact: [$a1:$a2:$a3:$a4:$a5:$a6]"
- grep "^$a1:$a2:$a3:$a4:$a5:$a6$" $depends_status

+ lock_file "$depends_status"
+ grep "^$a1:$a2:$a3:$a4:$a5:$a6$" "$depends_status"
+ rc=$?
+ unlock_file "$depends_status"
+
+ return $rc
}

#---------------------------------------------------------------------
@@ -110,8 +121,9 @@ function search_depends_status_simple()
a5=`esc_str "$5"`; a6=`esc_str "$6"`
a5=${5:-.*} ; a6=${6:-.*}

- grep "^$a1:$a2\(([^:]*)\)\?:$a3:$a4:$a5:$a6$" $depends_status
-
+ lock_file "$depends_status"
+ grep "^$a1:$a2\(([^:]*)\)\?:$a3:$a4:$a5:$a6$" "$depends_status"
+ unlock_file "$depends_status"
}


@@ -130,12 +142,17 @@ function search_depends_status_simple()
function search_depends_status()
{ # $1=depends file $2=spell, $3=(opt)depends

+ [[ -z $2 ]] && return 1
local depends_status=$1
shift

- [ $# -eq 1 ] && grep "^`esc_str "$1"`:" $depends_status
- [ $# -gt 1 ] && grep "^`esc_str "$1"`:`esc_str "$2"`:" $depends_status
-
+ lock_file "$depends_status"
+ if [[ -z $2 ]]; then
+ grep "^`esc_str "$1"`:" "$depends_status"
+ else
+ grep "^`esc_str "$1:$2"`:" "$depends_status"
+ fi
+ unlock_file "$depends_status"
}


@@ -165,7 +182,9 @@ function get_depends_options()

local START="$(esc_str $1)"
debug "libstate" "get_depends_options() - START=$START"
+ lock_file "$depends_status"
awk -F ':' -v start=$START "{ if (\$1 == start) if (\$3 == \"on\") OPTS =
OPTS \" \" \$5; else OPTS = OPTS \" \" \$6; } END { print OPTS; }"
$depends_status 2> /dev/null
+ unlock_file "$depends_status"
}


@@ -202,8 +221,9 @@ function remove_depends_status()
a5=${a5:-.*}; a6=${a6:-.*}
[[ "$a5" == "[none]" ]] && a5="\\[none\\]"

- sedit "/^$a1:$a2:$a3:$a4:$a5:$a6$/D" $depends_status
-
+ local t_status=$(lock_start_transaction "$depends_status")
+ sedit "/^$a1:$a2:$a3:$a4:$a5:$a6$/D" "$t_status"
+ lock_commit_transaction "$depends_status"
}

#---------------------------------------------------------------------
@@ -287,8 +307,10 @@ function add_sub_depends() {
remove_sub_depends "$@" || return 1
local file=$1
shift
- # FIXME LOCK
- echo "$1:$2:$3" >> "$file"
+
+ local t_file=$(lock_start_transaction "$file")
+ echo "$1:$2:$3" >> "$t_file"
+ lock_commit_transaction "$file"
}

#---------------------------------------------------------------------
@@ -308,8 +330,10 @@ function search_sub_depends() {
a1=${a1:-.*}
a2=${a2:-.*}
a3=${a3:-.*}
- # FIXME LOCK
+
+ lock_file "$file"
grep "^$a1:$a2:$a3$" "$file"
+ unlock_file "$file"
}

#---------------------------------------------------------------------
@@ -331,8 +355,9 @@ function remove_sub_depends() {
a1=`esc_str "$1"`; a2=`esc_str "$2"`; a3=`esc_str "$3"`
a1=${a1:-.*}; a2=${a2:-.*}; a3=${a3:-.*}

- # FIXME LOCK
- sedit "/^$a1:$a2:$a3$/D" "$file"
+ local t_file=$(lock_start_transaction "$file")
+ sedit "/^$a1:$a2:$a3$/D" "$t_file"
+ lock_commit_transaction "$file"
}

#---------------------------------------------------------------------
@@ -420,7 +445,9 @@ function remove_default_depends() {

a3=${a3:-.*}

- sedit "/^$a1:$a2:$a3$/D" $file
+ local t_file=$(lock_start_transaction "$file")
+ sedit "/^$a1:$a2:$a3$/D" $t_file
+ lock_commit_transaction "$file"
}

#---------------------------------------------------------------------
@@ -444,7 +471,12 @@ function search_default_depends() {
a3=${a3:-.*}

debug "libstate" "search_default_depends: [$a1:$a2:$a3]"
+ lock_file "$default_depends"
grep "^$a1:$a2:$a3$" $default_depends
+ rc=$?
+ unlock_file "$default_depends"
+
+ return $rc
}


@@ -553,10 +585,17 @@ function add_spell() {
##
#---------------------------------------------------------------------
function search_spell_status() {
+ [[ -z $2 ]] && return 1
local spell_status=$1
shift
- [ $# -eq 1 ] && grep "^`esc_str "$1"`:" $spell_status
- [ $# -gt 1 ] && grep "^`esc_str "$1"`:`esc_str "$2"`:" $spell_status
+
+ lock_file "$spell_status"
+ if [[ -z $2 ]]; then
+ grep "^`esc_str "$1"`:" $spell_status
+ else
+ grep "^`esc_str "$1:$2"`:" $spell_status
+ fi
+ unlock_file "$spell_status"
}

#---------------------------------------------------------------------
@@ -580,8 +619,13 @@ function query_spell_status()
local version
version=`esc_str ${2:-".*"}`

+ lock_file "$SPELL_STATUS"
tac $SPELL_STATUS | grep -m 1 "^$1:.*:.*:$version$" | \
cut -d ":" -f 3
+ rc=$?
+ unlock_file "$SPELL_STATUS"
+
+ return $rc
}

#---------------------------------------------------------------------
@@ -727,9 +771,9 @@ function remove_spell() {
#---------------------------------------------------------------------
function all_spell_status()
{
-
+ lock_file "$SPELL_STATUS"
cat $SPELL_STATUS
-
+ unlock_file "$SPELL_STATUS"
}


@@ -740,7 +784,6 @@ function all_spell_status()
#---------------------------------------------------------------------
function set_held () {
local t_status=$(lock_start_transaction $SPELL_STATUS)
- cp $SPELL_STATUS $t_status
for to_hold in $@; do
sedit 's/\(^'$(esc_str $to_hold)':[^:]*:\)installed/\1held/'
$t_status
done
@@ -815,7 +858,6 @@ function set_unexiled () {
#---------------------------------------------------------------------
function set_unheld () {
local t_status=$(lock_start_transaction $SPELL_STATUS)
- cp $SPELL_STATUS $t_status
for to_hold in $@; do
sedit 's/\(^'$(esc_str $to_hold)':[^:]*:\)held/\1installed/'
$t_status
done



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (279988997c0ab5fd0a96f7b437f00296ec6f2110), Jaka Kranjc, 01/15/2008

Archive powered by MHonArc 2.6.24.

Top of Page