mirage / mirage-vnetif

Virtual network interface and software bridge for Mirage
ISC License
16 stars 14 forks source link

Add unregister_and_flush call #4

Closed MagnusS closed 8 years ago

MagnusS commented 8 years ago

Adds unregister_and_flush to allow a node to unregister from the backend and block until all that node's listener callbacks have returned. This is particularly useful when using async listeners, as they may still be processing packets after the listener has been removed from the backend.

Note that this may also block forever if the listener callbacks are not designed to return (such as in mirage-tcpip).

Each call to the listener callback now increments a counter per mac/node, which is decremented when the call returns and a condition variable is signalled. The new unregister_and_flush function will wait for the counter to reach 0 before unregistering the node id.