Closed jdstroy closed 2 years ago
@jdstroy could you share the patch for
Patching Meshtastic so that the (Python) thread that initializes TUN is also the same (Python) thread that calls tap.read() seems to work, although doing so makes tunnel.py a bit less useful as library code.
In my case:
root@abeilleDev:~# meshtastic --version
1.2.40
@KiwiHC16 Looks like you figured it out yourself. It seems you also figured out why I didn't submit a patch to "fix" it by removing the threading. :)
Turns out, my initial hunch was incorrect. I incorrectly assumed that the close() on fd 4 was happening because of file descriptor inheritance wackiness, but that's actually not the case; instead, it's a race condition, and I have a fix for that which I'll send in a PR in short order.
On Meshtastic 1.2.35 with Python 3.8.8, --tunnel appears to be broken:
Debugging this problem, it appears that the spawned thread at
Tunnel.__tunReader
throws an uncaught exception attap.read()
withEBADF
:Searching backwards, file descriptor 4 was opened by the parent process:
It seems tun does not work correctly when its file descriptor is copied from the parent process to the child process.
Patching Meshtastic so that the (Python) thread that initializes TUN is also the same (Python) thread that calls
tap.read()
seems to work, although doing so makestunnel.py
a bit less useful as library code.