Fix a race condition

This commit is contained in:
Mygod
2015-12-25 16:25:39 +08:00
parent 9fb0639f86
commit aed6308841
@@ -134,6 +134,7 @@ trait BaseService extends Service {
def updateTrafficTotal(tx: Long, rx: Long) {
val handler = new Handler(getContext.getMainLooper)
handler.post(() => {
val config = this.config // avoid race conditions without locking
if (config != null) {
ShadowsocksApplication.profileManager.getProfile(config.profileId) match {
case Some(profile) =>