[PATCH] ltq-dsl-base: only lock the dsl pipe once for all stats

Adrian Schmutzler mail at adrianschmutzler.de
Fri Dec 4 06:34:35 EST 2020


Hi,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of Andre Heider
> Sent: Freitag, 4. Dezember 2020 08:44
> To: openwrt-devel at lists.openwrt.org
> Subject: [PATCH] ltq-dsl-base: only lock the dsl pipe once for all stats
> 
> Instead of locking/unlocking it for every command.

please bump PKG_RELEASE.

Best

Adrian

> 
> Reduces the runtime for the dslstat/lucistat commands to ~66%.
> 
> Before:
> real	0m 2.66s
> user	0m 0.90s
> sys	0m 1.76s
> 
> After:
> real	0m 1.76s
> user	0m 0.63s
> sys	0m 1.13s
> 
> Signed-off-by: Andre Heider <a.heider at gmail.com>
> ---
>  .../files/lib/functions/lantiq_dsl.sh         | 21 +++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/package/network/utils/ltq-dsl-
> base/files/lib/functions/lantiq_dsl.sh b/package/network/utils/ltq-dsl-
> base/files/lib/functions/lantiq_dsl.sh
> index 39011f134f..89dc5c25c9 100755
> --- a/package/network/utils/ltq-dsl-base/files/lib/functions/lantiq_dsl.sh
> +++ b/package/network/utils/ltq-dsl-base/files/lib/functions/lantiq_dsl.
> +++ sh
> @@ -7,16 +7,24 @@ else
>  	XDSL_CTRL=dsl_cpe_control
>  fi
> 
> +DSL_PIPE_LOCKED=0
> +
>  #
>  # Basic functions to send CLI commands to the vdsl_cpe_control daemon  #
> +dsl_init() {
> +	killall -q -0 ${XDSL_CTRL} && lock /var/lock/dsl_pipe &&
> DSL_PIPE_LOCKED=1
> +	trap dsl_deinit EXIT INT KILL TERM
> +}
> +dsl_deinit() {
> +	test $DSL_PIPE_LOCKED -gt 0 && lock -u /var/lock/dsl_pipe &&
> DSL_PIPE_LOCKED=0
> +	exit
> +}
>  dsl_cmd() {
> -	killall -q -0 ${XDSL_CTRL} && (
> -		lock /var/lock/dsl_pipe
> -		echo "$@" > /tmp/pipe/dsl_cpe0_cmd
> -		cat /tmp/pipe/dsl_cpe0_ack
> -		lock -u /var/lock/dsl_pipe
> -	)
> +	test $DSL_PIPE_LOCKED -eq 0 && return
> +
> +	echo "$@" > /tmp/pipe/dsl_cpe0_cmd
> +	cat /tmp/pipe/dsl_cpe0_ack
>  }
>  dsl_val() {
>  	expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*'
> @@ -783,6 +791,7 @@ line_features() {
>  }
> 
>  dslstat() {
> +	dsl_init
>  	vendor
>  	chipset
>  	xtse
> --
> 2.29.2
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20201204/f1a927bb/attachment.sig>


More information about the openwrt-devel mailing list