item_updater: Skip functional version when freeing space

After the code update, the newly activated version would have a priority
value of 0. If the host is not rebooted, the functional version would
still be the old version but it'd now have a priority value of 1.

If another code update is requested at this point, the function that
frees up space would try to remove the highest priority version which
is the running one.

Add a check to ignore the version if it's the functional one, also
allow a version of priority 0 to be deleted.

Change-Id: I077ea2eeff68e07af533103f292be592326b5111
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/item_updater.cpp b/item_updater.cpp
index 05fbe00..adc6f7c 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -532,7 +532,11 @@
         if (iter.second.get()->activation() == server::Activation::Activations::Active)
         {
             count++;
-            if (iter.second->redundancyPriority.get()->priority() > highestPriority)
+            if (isVersionFunctional(iter.second->versionId))
+            {
+                continue;
+            }
+            if (iter.second->redundancyPriority.get()->priority() >= highestPriority)
             {
                 highestPriority = iter.second->redundancyPriority.get()->priority();
                 highestPriorityVersion = iter.second->versionId;