# You should have received a copy of the GNU Affero General Public License
# along with CGIlite. If not, see <http://www.gnu.org/licenses/>.
+[ -n "$include_storage" ] && return 0
+include_storage="$0"
+
LOCK(){
lock="${1}.lock"
timeout="${2-20}"
return 1
fi
- while ! mkdir "$lock"; do
+ while ! mkdir "$lock" 2>&-; do
block="$(cat "$lock/pid" || printf 1)"
if ! { ps -eo pid |grep -qwF "$block"; }; then
printf 'Overriding stale lock: %s\n' "$lock" >&2
sleep 1
done
printf '%i\n' $$ >"${lock}/pid"
- return 1
+ return 0
}
RELEASE(){
printf '%i\n' $$ >"${lock}/pid"
return 1
fi
+ return 0
else
printf 'Refusing to release foreign lock: %s\n' "$lock" >&2
return 1