mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Download && Upload Diagnostics: Add timeout to avoid hanging forever
This commit is contained in:
parent
074de2a2ca
commit
0f5e1c47b3
2 changed files with 8 additions and 2 deletions
|
|
@ -8,6 +8,8 @@
|
|||
ROOT="$(dirname $0)"
|
||||
. ${ROOT}/bbf_api
|
||||
|
||||
DOWNLOAD_TIMEOUT=1800
|
||||
|
||||
download_error() {
|
||||
json_init
|
||||
json_add_string "Status" "$1"
|
||||
|
|
@ -83,12 +85,13 @@ download_launch() {
|
|||
rx_bytes_start=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes)
|
||||
|
||||
time_start=$(date +"%s.282646") # It should be like that time_start=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded
|
||||
res=$(curl $ip_proto --fail --silent -w "$format" $url --output /dev/null)
|
||||
res=$(curl ${ip_proto} --fail --silent --max-time ${DOWNLOAD_TIMEOUT} -w "${format}" ${url} --output /dev/null)
|
||||
time_end=$(date +"%s.282646") # It should be like that time_end=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded
|
||||
|
||||
tx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes)
|
||||
rx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes)
|
||||
|
||||
logger -t "bbf_download" "########### ${url} ==> ${res} ###########"
|
||||
json_load "${res}"
|
||||
json_get_var size_download size_download
|
||||
json_get_var size_header size_header
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
ROOT="$(dirname $0)"
|
||||
. ${ROOT}/bbf_api
|
||||
|
||||
UPLOAD_TIMEOUT=1800
|
||||
|
||||
upload_error() {
|
||||
json_init
|
||||
json_add_string "Status" "$1"
|
||||
|
|
@ -92,12 +94,13 @@ upload_launch() {
|
|||
rx_bytes_start=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes)
|
||||
|
||||
time_start=$(date +"%s.282646") # It should be like that time_start=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded
|
||||
res=$(dd if=/dev/zero bs=$bs count=$count 2>/dev/null | curl $ip_proto --fail --silent -T - $url -w "$format")
|
||||
res=$(dd if=/dev/zero bs=$bs count=$count 2>/dev/null | curl ${ip_proto} --fail --silent --max-time ${UPLOAD_TIMEOUT} -T - ${url} -w "${format}")
|
||||
time_end=$(date +"%s.282646") # It should be like that time_end=$(date +"%s.%6N") but since OpenWrt busybox has limitations and doesn't support nonoseconds so keep it hardcoded
|
||||
|
||||
tx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.tx_bytes)
|
||||
rx_bytes_end=$(ubus call network.device status "{'name':'$device'}" | jsonfilter -e @.statistics.rx_bytes)
|
||||
|
||||
logger -t "bbf_upload" "########### ${url} ==> ${res} ###########"
|
||||
json_load "${res}"
|
||||
json_get_var size_upload size_upload
|
||||
json_get_var time_appconnect time_appconnect
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue