#!/bin/sh # Copyright (c) 2021 Proofpoint, Inc. and its suppliers. # All rights reserved. # # By using this file, you agree to the terms and conditions set # forth in the LICENSE file which can be found at the top level of # the sendmail distribution. # # ---------------------------------------- # test map locking. # Note: this is mostly for systems which use fcntl(). # just invoke it from the obj.*/libsmutil/ directory; # otherwise use the -l and -m options to specify the paths. # ---------------------------------------- fail() { echo "$0: $@" exit 1 } err() { echo "$0: $@" rc=1 } O=`basename $0`.0 V=vt M=../makemap/makemap CHKL=./t-lockfile usage() { cat <> $O 2>&1 } chkl() { ${CHKL} -Rrc -f $F >> $O 2>&1 } for XT in ${MAPTX} do MT=`echo $XT | cut -d: -f1` EXT=`echo $XT | cut -d: -f2` F=$V.${EXT} rm -f $O mm & wpid=$! sleep 1 chkl& rpid=$! while [ $tries -gt 0 ] do sleep 1; chkl tries=`expr $tries - 1 ` done wait $wpid wait $rpid if grep "status=unknown" $O >/dev/null then : else # get the makemap pid, not the "mm" pid, for checks? grep "status=locked pid=" $O || err "$MT map not locked" fi done exit $rc