Skip to content
Permalink
Browse files Browse the repository at this point in the history
Close and reopen parse_preprocessor_fd
This prevents parse_preprocessor from prepending a partial line from an old pinger binary instance with a full line from a new pinger binary instance.
  • Loading branch information
lynxthecat committed May 16, 2023
1 parent 9a04c73 commit 8f08b69
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions cake-autorate.sh
Expand Up @@ -524,10 +524,6 @@ parse_tsping()
dl_load_percent=0
ul_load_percent=0

exec {parse_preprocessor_fd}> >(parse_preprocessor)
parse_preprocessor_pid="${!}"
printf "SET_ARRAY_ELEMENT proc_pids %s %s\n" "${parse_id}_preprocessor" "${parse_preprocessor_pid}" >&"${main_fd}"

while true
do
unset command
Expand All @@ -542,6 +538,9 @@ parse_tsping()

START_PINGER)

exec {parse_preprocessor_fd}> >(parse_preprocessor)
parse_preprocessor_pid="${!}"
printf "SET_ARRAY_ELEMENT proc_pids %s %s\n" "${parse_id}_preprocessor" "${parse_preprocessor_pid}" >&"${main_fd}"
${ping_prefix_string} tsping ${ping_extra_args} --print-timestamps --machine-readable=' ' --sleep-time "0" --target-spacing "${ping_response_interval_ms}" "${reflectors[@]:0:${no_pingers}}" 2>/dev/null >&"${parse_preprocessor_fd}" &
pinger_pid="${!}"
printf "SET_ARRAY_ELEMENT proc_pids %s %s\n" "${parse_id}_pinger" "${pinger_pid}" >&"${main_fd}"
Expand All @@ -551,6 +550,7 @@ parse_tsping()
KILL_PINGER)

terminate "${pinger_pid}"
exec {parse_preprocessor_fd}>&-
continue
;;

Expand Down Expand Up @@ -680,10 +680,6 @@ parse_fping()
ul_load_percent=0
t_start_us="${EPOCHREALTIME/./}"

exec {parse_preprocessor_fd}> >(parse_preprocessor)
parse_preprocessor_pid="${!}"
printf "SET_ARRAY_ELEMENT proc_pids %s %s\n" "${parse_id}_preprocessor" "${parse_preprocessor_pid}" >&"${main_fd}"

while true
do
unset command
Expand All @@ -699,6 +695,9 @@ parse_fping()

START_PINGER)

exec {parse_preprocessor_fd}> >(parse_preprocessor)
parse_preprocessor_pid="${!}"
printf "SET_ARRAY_ELEMENT proc_pids %s %s\n" "${parse_id}_preprocessor" "${parse_preprocessor_pid}" >&"${main_fd}"
${ping_prefix_string} fping ${ping_extra_args} --timestamp --loop --period "${reflector_ping_interval_ms}" --interval "${ping_response_interval_ms}" --timeout 10000 "${reflectors[@]:0:${no_pingers}}" 2> /dev/null >&"${parse_preprocessor_fd}" &
pinger_pid="${!}"
printf "SET_ARRAY_ELEMENT proc_pids %s %s\n" "${parse_id}_pinger" "${pinger_pid}" >&"${main_fd}"
Expand All @@ -708,6 +707,7 @@ parse_fping()
KILL_PINGER)

terminate "${pinger_pid}"
exec {parse_preprocessor_fd}>&-
continue
;;

Expand Down Expand Up @@ -817,10 +817,6 @@ parse_ping()
dl_load_percent=0
ul_load_percent=0

exec {parse_preprocessor_fd}> >(parse_preprocessor)
parse_preprocessor_pid="${!}"
printf "SET_ARRAY_ELEMENT %s %s\n" "proc_pids ${parse_id}_preprocessor" "${parse_preprocessor_pid}" >&"${main_fd}"

while true
do
unset command
Expand All @@ -836,6 +832,9 @@ parse_ping()

START_PINGER)

exec {parse_preprocessor_fd}> >(parse_preprocessor)
parse_preprocessor_pid="${!}"
printf "SET_ARRAY_ELEMENT %s %s\n" "proc_pids ${parse_id}_preprocessor" "${parse_preprocessor_pid}" >&"${main_fd}"
${ping_prefix_string} ping ${ping_extra_args} -D -i "${reflector_ping_interval_s}" "${reflector}" 2> /dev/null >&"${parse_preprocessor_fd}" &
pinger_pid="${!}"
printf "SET_ARRAY_ELEMENT proc_pids %s %s\n" "${parse_id}_pinger" "${pinger_pid}" >&"${main_fd}"
Expand All @@ -845,6 +844,7 @@ parse_ping()
KILL_PINGER)

terminate "${pinger_pid}"
exec {parse_preprocessor_fd}>&-
continue
;;

Expand Down

0 comments on commit 8f08b69

Please sign in to comment.