Enable/disable inactive/active segments only
authorMartin Willi <martin@strongswan.org>
Wed, 23 Sep 2009 08:42:05 +0000 (10:42 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 7 Apr 2010 11:55:14 +0000 (13:55 +0200)
src/charon/plugins/ha_sync/ha_sync_segments.c

index 3bfc959..8929c62 100644 (file)
@@ -127,13 +127,19 @@ static void enable_disable(private_ha_sync_segments_t *this, u_int segment,
                {
                        if (enable)
                        {
-                               this->active |= SEGMENTS_BIT(i);
-                               this->kernel->activate(this->kernel, i);
+                               if (!(this->active & SEGMENTS_BIT(i)))
+                               {
+                                       this->active |= SEGMENTS_BIT(i);
+                                       this->kernel->activate(this->kernel, i);
+                               }
                        }
                        else
                        {
-                               this->active &= ~SEGMENTS_BIT(i);
-                               this->kernel->deactivate(this->kernel, i);
+                               if (this->active & SEGMENTS_BIT(i))
+                               {
+                                       this->active &= ~SEGMENTS_BIT(i);
+                                       this->kernel->deactivate(this->kernel, i);
+                               }
                        }
                }