Bladeren bron

when swapping interfaces, the wrong one is trashed!

Caleb James DeLisle 9 jaren geleden
bovenliggende
commit
efc21cf30e
2 gewijzigde bestanden met toevoegingen van 7 en 3 verwijderingen
  1. 5 0
      net/InterfaceController.c
  2. 2 3
      switch/SwitchCore.c

+ 5 - 0
net/InterfaceController.c

@@ -378,7 +378,12 @@ static void moveEndpointIfNeeded(struct Peer* ep)
 
             ep->addr.path = thisEp->addr.path;
             SwitchCore_swapInterfaces(&thisEp->switchIf, &ep->switchIf);
+
+            Assert_true(ep->switchIf.connectedIf->send);
+            Assert_true(thisEp->switchIf.connectedIf->send);
             Allocator_free(thisEp->alloc);
+            Assert_true(!thisEp->switchIf.connectedIf->send);
+            Assert_true(ep->switchIf.connectedIf->send);
             return;
         }
     }

+ 2 - 3
switch/SwitchCore.c

@@ -259,9 +259,8 @@ void SwitchCore_swapInterfaces(struct Iface* userIf1, struct Iface* userIf2)
     Bits_memcpyConst(si1, si2, sizeof(struct SwitchInterface));
     Bits_memcpyConst(si2, &si3, sizeof(struct SwitchInterface));
 
-    // Now the if#'s are in reverse order :)
-    si1->onFree = Allocator_onFree(si2->alloc, removeInterface, si1);
-    si2->onFree = Allocator_onFree(si1->alloc, removeInterface, si2);
+    si1->onFree = Allocator_onFree(si1->alloc, removeInterface, si1);
+    si2->onFree = Allocator_onFree(si2->alloc, removeInterface, si2);
 
     Iface_plumb(userIf2, &si1->iface);
     Iface_plumb(userIf1, &si2->iface);