[PATCH v3 1/3] ltq-dsl-base: only lock the dsl pipe once for all stats
Andre Heider
a.heider at gmail.com
Fri Dec 4 08:32:45 EST 2020
Instead of locking/unlocking it for every command.
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>
---
v2: bump PKG_RELEASE
v3: use flock style suggested by Jo, bump release in different patch
.../files/lib/functions/lantiq_dsl.sh | 35 ++++++++++---------
1 file changed, 18 insertions(+), 17 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 5842a7879f..1a28633c79 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
@@ -11,12 +11,8 @@ fi
# Basic functions to send CLI commands to the vdsl_cpe_control daemon
#
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
- )
+ echo "$@" > /tmp/pipe/dsl_cpe0_cmd
+ cat /tmp/pipe/dsl_cpe0_ack
}
dsl_val() {
expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*'
@@ -729,17 +725,22 @@ profile() {
}
dslstat() {
- vendor
- chipset
- xtse
- profile
- line_state
- errors
- power_mode
- latency_delay
- data_rates
- line_data
- line_uptime
+ killall -q -0 ${XDSL_CTRL} || exit 1
+ (
+ flock -x 323
+
+ vendor
+ chipset
+ xtse
+ profile
+ line_state
+ errors
+ power_mode
+ latency_delay
+ data_rates
+ line_data
+ line_uptime
+ ) 323> /var/lock/dsl_pipe
}
lucistat() {
--
2.29.2
More information about the openwrt-devel
mailing list