The problem with Listen/Unlisten in the port toggle endpoint

So if we have PeerListener listening for peers on an interface it has a couple of open sockets using that interface. This is all find and dandy even if the interface has nothing plugged in, because any interface is possible to bind on and has the needed fe80 address assigned by the operating system.

The issue is this, while we are building the uci interface we will then listen on during port function toggling the interface doesn’t actually exist, we need to add it to the listen list about a minute after we end execution of this function to give the OS time to finish the refresh of the settings and assign addresses to the new interface. This task is handled for us during boot because we request to come up after the network target.

My current thought is to issue a future to listen to the interface after sleeping for 60 seconds (hopefully with some futures library for sleeping so that we don’t block for a whole minute. That way the interface can come back right away then come into effect a few seconds later.

The alternative is to try and do this synchronously. Which will involve an enormous wait.

Ok, so to see if I’m following correctly-

  1. Setting up a mesh interface involves a 60 second wait
  2. We should wait using a future so that we don’t block everything

Seems pretty reasonable. What’s the question?

If that is a correct understanding then I suppose we will want to display a “Waiting” state in the interface or something

well there are lots of ways that could go wrong since we can’t wait for the future.

Can you clarify?

well lets say our function somehow fails on uci commit now we have this future we’ve already issued and have no way to get back waiting to execute and fail, of course we could delay it until the very last second but that makes things a little messy, not that it’s the end of the world if that happens