shill: Adds informational output when ScanSession finishes.
BUG=None.
TEST=unittest and manual. For manual test, in crosh window on
target chrome device:
* shell
* sudo bash
* stop shill
* shill --log-level=-10 --log-scopes=wifi
* look in /var/log/net.log for:
------ ScanSession finished ------
Scanned <n> frequencies (<m> remaining)
Change-Id: Iba9f95215172b12c805fc534be1f1500b3bdd095
Reviewed-on: https://gerrit.chromium.org/gerrit/57272
Commit-Queue: Wade Guthrie <wdg@chromium.org>
Reviewed-by: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
diff --git a/scan_session.cc b/scan_session.cc
index a4f8d49..254ce97 100644
--- a/scan_session.cc
+++ b/scan_session.cc
@@ -58,6 +58,7 @@
max_frequencies_(max_frequencies),
on_scan_failed_(on_scan_failed),
scan_tries_left_(kScanRetryCount),
+ found_error_(false),
metrics_(metrics) {
sort(frequency_list_.begin(), frequency_list_.end(),
&ScanSession::CompareFrequencyCount);
@@ -80,12 +81,13 @@
<< freq_conn.connection_count;
}
+ original_frequency_count_ = frequency_list_.size();
ebusy_timer_.Pause();
}
ScanSession::~ScanSession() {
const int kLogLevel = 6;
- ReportEbusyTime(kLogLevel);
+ ReportResults(kLogLevel);
}
bool ScanSession::HasMoreFrequencies() const {
@@ -206,6 +208,7 @@
const NetlinkMessage *netlink_message) {
if (!netlink_message) {
LOG(ERROR) << __func__ << ": Message failed: NetlinkManager Error.";
+ found_error_ = true;
on_scan_failed_.Run();
return;
}
@@ -223,6 +226,7 @@
if (scan_tries_left_ == 0) {
LOG(ERROR) << "Retried progressive scan " << kScanRetryCount
<< " times and failed each time. Giving up.";
+ found_error_ = true;
on_scan_failed_.Run();
scan_tries_left_ = kScanRetryCount;
return;
@@ -236,13 +240,27 @@
kScanRetryDelayMilliseconds);
return;
}
+ found_error_ = true;
on_scan_failed_.Run();
} else {
SLOG(WiFi, 6) << __func__ << ": Message ACKed";
}
}
-void ScanSession::ReportEbusyTime(int log_level) {
+void ScanSession::ReportResults(int log_level) {
+ SLOG(WiFi, log_level) << "------ ScanSession finished ------";
+ SLOG(WiFi, log_level) << "Scanned "
+ << original_frequency_count_ - frequency_list_.size()
+ << " frequencies (" << frequency_list_.size()
+ << " remaining)";
+ if (found_error_) {
+ SLOG(WiFi, log_level) << "ERROR encountered during scan ("
+ << current_scan_frequencies_.size() << " frequencies"
+ << " dangling - counted as scanned but, really, not)";
+ } else {
+ SLOG(WiFi, log_level) << "No error encountered during scan.";
+ }
+
base::TimeDelta elapsed_time;
ebusy_timer_.GetElapsedTime(&elapsed_time);
if (metrics_) {
diff --git a/scan_session.h b/scan_session.h
index fac38d0..de02911 100644
--- a/scan_session.h
+++ b/scan_session.h
@@ -183,6 +183,9 @@
void ReportEbusyTime(int log_level);
+ // Logs the results of the scan.
+ void ReportResults(int log_level);
+
base::WeakPtrFactory<ScanSession> weak_ptr_factory_;
NetlinkManager *netlink_manager_;
@@ -202,8 +205,10 @@
size_t max_frequencies_;
OnScanFailed on_scan_failed_;
size_t scan_tries_left_;
+ bool found_error_;
// Statistics gathering.
+ size_t original_frequency_count_;
chromeos_metrics::Timer ebusy_timer_;
Metrics *metrics_;