Skip to content

Tunnel service bugs #1420

Closed
Closed
@vToMy

Description

@vToMy

There are 2 bugs in tunnel_service.py:

await super().stop_tunnel()

super().stop_tunnel should be called after closing _sock_read_task but before closing the writer.
This is the proper order to stop these because of their dependency on each other. It will prevent warning logs in tun_read_task

async with aiofiles.open(self.tun.fileno(), 'rb', opener=lambda path, flags: path, buffering=0) as f:

Don't use aiofiles to read from the tun. Just read normally (with asyncio.to_thread).
The problem here is that using a context manager on the raw file descriptor actually closes it when this is not intended (it will be closed when the tun is closed). Also, this can cause rare file descriptor issues due to the socket being closed but python not aware of it, so when the OS reuses the same fd some later time python will complain it's already in use. It happened to me a couple of times and this solves it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions