From 4eb78676952aee0030447bfbe04091bb6669bb77 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Mon, 21 Apr 2014 23:24:21 +0300 Subject: [PATCH] Remove old pending tasks when the device sends bootstrap event --- lib/cwmp.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cwmp.coffee b/lib/cwmp.coffee index 05e48c3..6cda906 100644 --- a/lib/cwmp.coffee +++ b/lib/cwmp.coffee @@ -137,7 +137,13 @@ inform = (currentRequest, cwmpRequest) -> actions = {parameterValues : cwmpRequest.methodRequest.parameterList, set : {}} actions.set._lastInform = now actions.set._lastBoot = now if '1 BOOT' in cwmpRequest.methodRequest.event - actions.set._lastBootstrap = lastBootstrap = now if '0 BOOTSTRAP' in cwmpRequest.methodRequest.event + + if '0 BOOTSTRAP' in cwmpRequest.methodRequest.event + actions.set._lastBootstrap = lastBootstrap = now + # ignore all pending tasks + db.tasksCollection.remove({device : currentRequest.deviceId}, (err, removed) -> + throw err if err + ) db.redisClient.get("#{currentRequest.deviceId}_inform_hash", (err, oldInformHash) -> throw err if err