diff options
author | Bryan Drewery <bryan@shatow.net> | 2020-05-28 20:57:42 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2021-09-03 02:20:24 +0300 |
commit | e013f0a933578b8ca362984b2f5d0c4f7f4b041f (patch) | |
tree | f9980cd6652189f391281e104ce6ec4beb44fa37 /src | |
parent | ad5828ed33a0aa10ff0dad31de3f1587704781b7 (diff) |
locks don't need critical sections now
locked_mkdir is the implementation of the lock and supports checking for
stale locks so, in general, it's fine if a process dies while holding it.
Commit 1e49c25ec4e2f4597bec6c16ebdccba984fd239b added this feature
because the html_json process was exiting while holding a lock. We
still need to ensure a consistent stats writing from there though.
Also remove stale comemnt.
Diffstat (limited to 'src')
-rw-r--r-- | src/share/poudriere/common.sh | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index ba51cdd7..9ccbe711 100644 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -1162,6 +1162,7 @@ update_stats() { set +e lock_acquire update_stats || return 1 + critical_start for type in built failed ignored; do _bget '' "ports.${type}" @@ -1173,6 +1174,7 @@ update_stats() { sort -u | wc -l) lock_release update_stats + critical_end } update_stats_queued() { @@ -5900,9 +5902,6 @@ _lock_acquire() { local waittime="${3:-30}" local have_lock mypid lock_pid - # Delay TERM/INT while holding the lock - critical_start - mypid="$(getpid)" hash_get have_lock "${lockname}" have_lock || have_lock=0 # lock_pid is in case a subshell tries to reacquire/relase my lock @@ -5917,7 +5916,6 @@ _lock_acquire() { if [ "${have_lock}" -eq 0 ] && ! locked_mkdir "${waittime}" "${lockpath}" "${mypid}"; then msg_warn "Failed to acquire ${lockname} lock" - critical_end return 1 fi hash_set have_lock "${lockname}" $((have_lock + 1)) @@ -5981,8 +5979,6 @@ _lock_release() { rmdir "${lockpath}" || err 1 "Held lock dir not found: ${lockpath}" fi - # Restore and deliver INT/TERM signals - critical_end } # Release local build lock @@ -7636,8 +7632,6 @@ prepare_ports() { fi show_log_info - # Must acquire "update_stats" on shutdown to ensure - # the process is not killed while holding it. if [ ${HTML_JSON_UPDATE_INTERVAL} -ne 0 ]; then coprocess_start html_json else |