shill: improve log message in vpn_service
When we skip a connect request because the service is already
connected, or connecting, log the fact that either is a possibility.
BUG=None
TEST=unit tests
Change-Id: I82ad783482d5b2bf02812860c44fe9830f06ce00
Reviewed-on: https://gerrit.chromium.org/gerrit/57487
Commit-Queue: mukesh agrawal <quiche@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
diff --git a/vpn_service.cc b/vpn_service.cc
index 0e8771d..fcf3aa0 100644
--- a/vpn_service.cc
+++ b/vpn_service.cc
@@ -43,9 +43,16 @@
VPNService::~VPNService() {}
void VPNService::Connect(Error *error, const char *reason) {
- if (IsConnected() || IsConnecting()) {
- Error::PopulateAndLog(
- error, Error::kAlreadyConnected, "VPN service already connected.");
+ if (IsConnected()) {
+ Error::PopulateAndLog(error, Error::kAlreadyConnected,
+ StringPrintf("VPN service %s already connected.",
+ unique_name().c_str()));
+ return;
+ }
+ if (IsConnecting()) {
+ Error::PopulateAndLog(error, Error::kInProgress,
+ StringPrintf("VPN service %s already connecting.",
+ unique_name().c_str()));
return;
}
Service::Connect(error, reason);
diff --git a/vpn_service_unittest.cc b/vpn_service_unittest.cc
index 17e91fb..0517d51 100644
--- a/vpn_service_unittest.cc
+++ b/vpn_service_unittest.cc
@@ -125,7 +125,7 @@
error.Reset();
SetServiceState(Service::kStateConfiguring);
service_->Connect(&error, "in test");
- EXPECT_EQ(Error::kAlreadyConnected, error.type());
+ EXPECT_EQ(Error::kInProgress, error.type());
}
TEST_F(VPNServiceTest, Disconnect) {