Skip to content

Commit 60cf4b1

Browse files
committed
Synchronize events more precisely.
1 parent 678305f commit 60cf4b1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test_run.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ fi
2020

2121
PYTHON_CMD="${PYTHON_CMD:-"python"}"
2222

23+
sleep_until() {
24+
${PYTHON_CMD} -c "from time import time, sleep; tleft=${SIPLOG_TSTART} + ${1} - time(); sleep(tleft) if tleft > 0 else False;"
25+
}
26+
2327
rtpproxy_cmds_gen() {
2428
if [ x"${RTPP_PRE_STAT_TIMEOUT}" != x"" ]
2529
then
26-
sleep ${RTPP_PRE_STAT_TIMEOUT}
30+
sleep_until ${RTPP_PRE_STAT_TIMEOUT}
2731
cat "${BUILDDIR}/rtpproxy.stats.input"
28-
RTPP_STAT_TIMEOUT=$((${RTPP_STAT_TIMEOUT} - ${RTPP_PRE_STAT_TIMEOUT}))
2932
fi
30-
sleep ${RTPP_STAT_TIMEOUT}
33+
sleep_until ${RTPP_STAT_TIMEOUT}
3134
cat "${BUILDDIR}/rtpproxy.stats.input"
3235
}
3336

@@ -166,7 +169,7 @@ start_mm() {
166169

167170
ALICE_ARGS="${ALICE_ARGS:-"-46"}"
168171
echo ${MM_PID} > "${MM_PIDF}"
169-
sleep ${MM_INIT_DELAY}
172+
sleep_until ${MM_INIT_DELAY}
170173
return 0
171174
}
172175

@@ -277,7 +280,7 @@ if [ ${ALICE_RC} -eq 0 -a ${BOB_RC} -eq 0 -a ${MM_RC} -eq 0 ]
277280
then
278281
# Always give the RTPproxy enough time to execute final stats command,
279282
# before we SIGHUP it
280-
${PYTHON_CMD} -c "from time import time, sleep; tleft=${SIPLOG_TSTART} + ${RTPP_STAT_TIMEOUT} + 5 - time(); sleep(tleft) if tleft > 0 else False;"
283+
sleep_until $((${RTPP_STAT_TIMEOUT} + 6))
281284
fi
282285
if [ "${RTPPC_TYPE}" != "rtp.io" ]
283286
then

0 commit comments

Comments
 (0)