[LEDE-DEV] [PATCH 1/2] procd/base-files: move init.d locking to rc.common
John Crispin
john at phrozen.org
Thu Jan 18 00:30:07 PST 2018
On 18/01/18 09:14, John Crispin wrote:
> rather than using flock for procd enabled services we add locking to the
> rc.common code.
>
> Signed-off-by: John Crispin <john at phrozen.org>
> ---
> package/base-files/files/etc/rc.common | 6 ++++++
> package/system/procd/files/procd.sh | 15 ---------------
> 2 files changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
> index 3e237170b4..180ee83acd 100755
> --- a/package/base-files/files/etc/rc.common
> +++ b/package/base-files/files/etc/rc.common
> @@ -148,4 +148,10 @@ ${INIT_TRACE:+set -x}
>
> ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
> list_contains ALL_COMMANDS "$action" || action=help
> +
> +local basescript=$(readlink "$initscript")
> +local service_name="$(basename ${basescript:-$initscript})"
> +
> +lock -w /var/lock/init.d_${service_name}.lock
the -w is wrong here and needs to be removed
John`
> $action "$@"
> +lock -u /var/lock/init.d_${service_name}.lock
> diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh
> index b4b6faa662..b7d7b94ff1 100644
> --- a/package/system/procd/files/procd.sh
> +++ b/package/system/procd/files/procd.sh
> @@ -38,20 +38,6 @@
> PROCD_RELOAD_DELAY=1000
> _PROCD_SERVICE=
>
> -procd_lock() {
> - local basescript=$(readlink "$initscript")
> - local service_name="$(basename ${basescript:-$initscript})"
> -
> - flock -n 1000 &> /dev/null
> - if [ "$?" != "0" ]; then
> - exec 1000>/var/lock/procd_${service_name}.lock
> - flock 1000
> - if [ "$?" != "0" ]; then
> - logger "warning: procd flock for $service_name failed"
> - fi
> - fi
> -}
> -
> _procd_call() {
> local old_cb
>
> @@ -61,7 +47,6 @@ _procd_call() {
> }
>
> _procd_wrapper() {
> - procd_lock
> while [ -n "$1" ]; do
> eval "$1() { _procd_call _$1 \"\$@\"; }"
> shift
More information about the Lede-dev
mailing list