From aee5528149d04f43eea2c682a92ca5cb50bf8250 Mon Sep 17 00:00:00 2001
From: Thulinma <jaron@vietors.com>
Date: Fri, 7 Sep 2012 12:36:09 +0200
Subject: [PATCH] Solved a race condition bug in the controller causing it not
 to exit properly.

---
 src/controller.cpp | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/controller.cpp b/src/controller.cpp
index 181fb24e..00bd5bac 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -271,15 +271,8 @@ void CheckStats(JSON::Value & stats){
           if (u_it->second.isMember("now") && u_it->second["now"].asInt() < nowtime - 3){
             jit->second["log"].append(u_it->second);
             jit->second["curr"].removeMember(u_it->first);
-            if (jit->second["curr"].size() < 1){
-              break;
-            }else{
-              if (jit->second["curr"].ObjBegin() != u_it){
-                u_it--;
-              }else{
-                u_it = jit->second["curr"].ObjBegin();
-              }
-            }
+            if (!jit->second["curr"].size()){break;}
+            u_it = jit->second["curr"].ObjBegin();
           }
         }
       }