Perf improvements mac in wait_kill()

This commit is contained in:
Dirk
2025-07-21 18:50:24 +02:00
parent d638843cc1
commit be50597b47

View File

@@ -270,6 +270,8 @@ PARENT_CSVFILE="" # csvfile if mass testing and all output
PARENT_HTMLFILE="" # HTML if mass testing and all output sent to a single file PARENT_HTMLFILE="" # HTML if mass testing and all output sent to a single file
TIMEOUT_CMD="" TIMEOUT_CMD=""
HAD_SLEPT=0 HAD_SLEPT=0
SWK_SECs=0.1 # Tuning var SLEEP_WAITKILL in secs. Better don't touch it. SWK_SECs * SWK_FACTOR needs to ne equal 1
SWK_FACTOR=10 # Tuning var SLEEP_WAITKILL FACTOR in secs. Better don't touch it.
NR_SOCKET_FAIL=0 # Counter for socket failures NR_SOCKET_FAIL=0 # Counter for socket failures
NR_OSSL_FAIL=0 # .. for OpenSSL connects NR_OSSL_FAIL=0 # .. for OpenSSL connects
NR_STARTTLS_FAIL=0 # .. for STARTTLS failures NR_STARTTLS_FAIL=0 # .. for STARTTLS failures
@@ -2228,30 +2230,33 @@ check_revocation_ocsp() {
fi fi
} }
# waits maxsleep seconds (arg2) until process with arg1 (pid) will be killed
# waits maxsleep fractions of seconds (arg2) until process with arg1 (pid) will be killed
# #
# return values # return values
# 0: process terminated before be killed # 0: process terminated before be killed
# 3: was killed # 3: was killed
# #
wait_kill(){ wait_kill(){
local pid=$1 # pid we wait for or kill local pid=$1 # pid we wait for or kill
local maxsleep=$2 # how long we wait before killing local maxsleep=$2 # how long we wait before killing
maxsleep=$((maxsleep*SWK_FACTOR))
HAD_SLEPT=0 HAD_SLEPT=0
while true; do while true; do
if ! ps $pid >/dev/null ; then if ! ps $pid >/dev/null ; then
return 0 # process terminated before didn't reach $maxsleep return 0 # process terminated before didn't reach $maxsleep
fi fi
[[ "$DEBUG" -ge 6 ]] && ps $pid [[ "$DEBUG" -ge 6 ]] && ps $pid
sleep 1 sleep $SWK_SECs
maxsleep=$((maxsleep - 1)) maxsleep=$((maxsleep - 1))
#FIXME: HAD_SLEPT currently assumes we slep one second but only used by run_http_header()
HAD_SLEPT=$((HAD_SLEPT + 1)) HAD_SLEPT=$((HAD_SLEPT + 1))
test $maxsleep -le 0 && break test $maxsleep -le 0 && break
done # needs to be killed: done # needs to be killed:
kill $pid >&2 2>/dev/null kill $pid >&2 2>/dev/null
wait $pid 2>/dev/null # make sure pid terminated, see wait(1p) wait $pid 2>/dev/null # make sure pid terminated, see wait(1p)
return 3 # means killed return 3 # means killed
} }
# Convert date formats -- we always use GMT=UTC here # Convert date formats -- we always use GMT=UTC here
@@ -2582,6 +2587,7 @@ sanitze_http_header() {
#problems not handled: chunked #problems not handled: chunked
#
run_http_header() { run_http_header() {
local header local header
local referer useragent local referer useragent