From 70aa867c53a8db7f994e61c3db7d9fa0366dd672 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Wed, 4 May 2016 08:58:46 +0800 Subject: [PATCH] Fix a race condition --- .../com/github/shadowsocks/Shadowsocks.scala | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala index ebc771d3..a149cc92 100644 --- a/src/main/scala/com/github/shadowsocks/Shadowsocks.scala +++ b/src/main/scala/com/github/shadowsocks/Shadowsocks.scala @@ -208,6 +208,8 @@ class Shadowsocks .putString(Key.proxied, DBHelper.updateProxiedApps(this, oldProxiedApps)).apply() recovery() + + updateCurrentProfile() } } @@ -496,10 +498,7 @@ class Shadowsocks } } - protected override def onResume() { - super.onResume() - ConfigUtils.refresh(this) - + private def updateCurrentProfile() { // Check if current profile changed if (ShadowsocksApplication.profileId != currentProfile.id) { currentProfile = ShadowsocksApplication.currentProfile match { @@ -515,6 +514,14 @@ class Shadowsocks if (serviceStarted) serviceLoad() } + } + + protected override def onResume() { + super.onResume() + + ConfigUtils.refresh(this) + + updateCurrentProfile() updateState() }