Repository: yetus Updated Branches: refs/heads/master dae92001d -> 287e586b6
Revert "YETUS-581. bash 3 throws syntax errors on coproc statements" This reverts commit dae92001d2db74a05090a514aa54bc6b63e86434. Project: http://git-wip-us.apache.org/repos/asf/yetus/repo Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/287e586b Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/287e586b Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/287e586b Branch: refs/heads/master Commit: 287e586b6e9bf23c2eb4a634c0fa71446e53bd69 Parents: dae9200 Author: Allen Wittenauer <[email protected]> Authored: Fri Nov 10 13:34:10 2017 -0800 Committer: Allen Wittenauer <[email protected]> Committed: Fri Nov 10 13:34:10 2017 -0800 ---------------------------------------------------------------------- precommit/coprocs.d/README.md | 25 --------- precommit/coprocs.d/e_a_r_helper.sh | 34 ------------ precommit/coprocs.d/process_counter.sh | 47 ----------------- precommit/coprocs.d/reaper.sh | 27 ---------- precommit/test-patch.sh | 82 +++++++++++++++++++++-------- 5 files changed, 59 insertions(+), 156 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/yetus/blob/287e586b/precommit/coprocs.d/README.md ---------------------------------------------------------------------- diff --git a/precommit/coprocs.d/README.md b/precommit/coprocs.d/README.md deleted file mode 100755 index e960cad..0000000 --- a/precommit/coprocs.d/README.md +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -############################# -## -## bash v4+ coproc routines -## -############################# - -# bash v3 and lower will treat coproc commands as syntax errors -# therefore, ALL functions which activate coprocs are located -# here \ No newline at end of file http://git-wip-us.apache.org/repos/asf/yetus/blob/287e586b/precommit/coprocs.d/e_a_r_helper.sh ---------------------------------------------------------------------- diff --git a/precommit/coprocs.d/e_a_r_helper.sh b/precommit/coprocs.d/e_a_r_helper.sh deleted file mode 100755 index 7b41b24..0000000 --- a/precommit/coprocs.d/e_a_r_helper.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# SHELLDOC-IGNORE - -## @description helper function for echo_and_redirect -## @audience private -## @stability evolving -## @replaceable no -function e_a_r_helper -{ - declare logfile=$1 - shift - declare params=("${@}") - - # shellcheck disable=SC2034 - coproc yrr_coproc { - ulimit -Su "${PROC_LIMIT}" - yetus_run_and_redirect "${logfile}" "${params[@]}" - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/yetus/blob/287e586b/precommit/coprocs.d/process_counter.sh ---------------------------------------------------------------------- diff --git a/precommit/coprocs.d/process_counter.sh b/precommit/coprocs.d/process_counter.sh deleted file mode 100755 index ddd247a..0000000 --- a/precommit/coprocs.d/process_counter.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# SHELLDOC-IGNORE - -function process_counter_coproc_start -{ - if [[ "${OSTYPE}" = Linux && "${DOCKERMODE}" = true ]]; then - # this is really only even remotely close to - # accurate under Docker, for the time being. - - # shellcheck disable=SC2034 - coproc process_counter_coproc { - declare threadcount - declare maxthreadcount - declare cmd - - sleep 2 - while true; do - threadcount=$(ps -L -u "${USER_ID}" -o lwp 2>/dev/null | wc -l) - if [[ ${threadcount} -gt ${maxthreadcount} ]]; then - maxthreadcount="${threadcount}" - echo "${maxthreadcount}" > "${PATCH_DIR}/threadcounter.txt" - fi - read -r -t 2 cmd - case "${cmd}" in - exit) - exit 0 - ;; - esac - done - } - fi -} http://git-wip-us.apache.org/repos/asf/yetus/blob/287e586b/precommit/coprocs.d/reaper.sh ---------------------------------------------------------------------- diff --git a/precommit/coprocs.d/reaper.sh b/precommit/coprocs.d/reaper.sh deleted file mode 100755 index 4427989..0000000 --- a/precommit/coprocs.d/reaper.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# SHELLDOC-IGNORE - -function reaper_coproc_start -{ - if [[ "${REAPER_MODE}" != "off" ]]; then - # shellcheck disable=SC2034 - coproc reaper_coproc { - reaper_coproc_func - } - fi -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/yetus/blob/287e586b/precommit/test-patch.sh ---------------------------------------------------------------------- diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh index 3d47795..b507101 100755 --- a/precommit/test-patch.sh +++ b/precommit/test-patch.sh @@ -623,6 +623,22 @@ function compute_unidiff rm "${tmpfile}" } +## @description helper function for echo_and_redirect +## @audience private +## @stability evolving +## @replaceable no +function e_a_r_helper +{ + declare logfile=$1 + shift + declare params=("${@}") + + # shellcheck disable=SC2034 + coproc yrr_coproc { + ulimit -Su "${PROC_LIMIT}" + yetus_run_and_redirect "${logfile}" "${params[@]}" + } +} ## @description Print the command to be executing to the screen. Then ## @description run the command, sending stdout and stderr to the given filename @@ -669,7 +685,7 @@ function echo_and_redirect # if bash < 4 (e.g., OS X), just run it # the ulimit was set earlier - yetus_run_and_redirect "${logfile}" "${@}" + yetus_run_and_redirect "${logfile}" "${params[@]}" fi } @@ -3037,26 +3053,48 @@ function distclean ## @replaceable yes function start_coprocessors { - - declare filename - # Eventually, we might open this up for plugins # and other operating environments # but for now, this is private and only for us if [[ "${BASH_VERSINFO[0]}" -gt 3 ]]; then - for filename in "${BINDIR}/coprocs.d"/*; do - # shellcheck disable=SC1091 - # shellcheck source=coprocs.d/process_counter.sh - . "${filename}" - done - determine_user - process_counter_coproc_start + if [[ "${OSTYPE}" = Linux && "${DOCKERMODE}" = true ]]; then + + # this is really only even remotely close to + # accurate under Docker, for the time being. - repear_coproc_start + # shellcheck disable=SC2034 + coproc process_counter_coproc { + declare threadcount + declare maxthreadcount + declare cmd + + sleep 2 + while true; do + threadcount=$(ps -L -u "${USER_ID}" -o lwp 2>/dev/null | wc -l) + if [[ ${threadcount} -gt ${maxthreadcount} ]]; then + maxthreadcount="${threadcount}" + echo "${maxthreadcount}" > "${PATCH_DIR}/threadcounter.txt" + fi + read -r -t 2 cmd + case "${cmd}" in + exit) + exit 0 + ;; + esac + done + } + fi + + if [[ "${REAPER_MODE}" != "off" ]]; then + # shellcheck disable=SC2034 + coproc reaper_coproc { + reaper_coproc_func + } + fi fi } @@ -3067,18 +3105,16 @@ function start_coprocessors ## @replaceable yes function stop_coprocessors { - if [[ "${BASH_VERSINFO[0]}" -gt 3 ]]; then - # shellcheck disable=SC2154 - if [[ -n "${process_counter_coproc_PID}" ]]; then - # shellcheck disable=SC2086 - echo exit >&${process_counter_coproc[1]} - fi + # shellcheck disable=SC2154 + if [[ -n "${process_counter_coproc_PID}" ]]; then + # shellcheck disable=SC2086 + echo exit >&${process_counter_coproc[1]} + fi - #shellcheck disable=SC2154 - if [[ -n "${reaper_coproc_PID}" ]]; then - # shellcheck disable=SC2086 - echo exit >&${reaper_coproc[1]} - fi + #shellcheck disable=SC2154 + if [[ -n "${reaper_coproc_PID}" ]]; then + # shellcheck disable=SC2086 + echo exit >&${reaper_coproc[1]} fi }
