Skip to content

Commit

Permalink
when swapping interfaces, the wrong one is trashed!
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdelisle committed Feb 27, 2015
1 parent b1fc8a2 commit efc21cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions net/InterfaceController.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
5 changes: 2 additions & 3 deletions switch/SwitchCore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit efc21cf

Please sign in to comment.