Skip to content

Some sockets are opened but never read. UDP socket buffer memory usage increases #171

@nicoladefranceschi

Description

@nicoladefranceschi

In the Zeroconf class init, some sockets:
https://github.com/jstasiak/python-zeroconf/blob/c7876108150cd251786db4ab52dadd1b2283d262/zeroconf.py#L1810

are created in both the unicast and multicast case.

But here:
https://github.com/jstasiak/python-zeroconf/blob/c7876108150cd251786db4ab52dadd1b2283d262/zeroconf.py#L1858-L1862
in case of multicast, the _respond_sockets are never read.

This causes some problem with the Recv queue of UDP, because the OS (in my case Ubuntu) keeps all the packets in memory waiting for the socket to read them, but this never happens and the memory keeps growing "forever"!

This is my output of sudo ss -nlpu:

State     Recv-Q     Send-Q                                Local Address:Port            Peer Address:Port                                                     
UNCONN    156416     0                                           0.0.0.0:5353                 0.0.0.0:*         users:(("python",pid=10571,fd=54))             

To solve:
I tried running these two lines
https://github.com/jstasiak/python-zeroconf/blob/c7876108150cd251786db4ab52dadd1b2283d262/zeroconf.py#L1861-L1862
even in the case of multicast.
The problem is "solved".

I'm sure that is not the right solution and may actually be logically wrong doing that for this case.
I'm not an expert, but maybe there is a way to actually tell the OS that those sockets are not interested in listening for packets.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions