Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 75057f07 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Avoid infinite loop in NetlinkListener.

Currently, NetlinkListener only reads from its socket if it gets
POLLIN. This means that if the kernel returns POLLERR without
POLLIN, it will get into an infinite loop.

Fix this by responding to POLLERR by issuing a recvfrom, which
clears the socket error, and continuing. The only error we expect
to see here is ENOBUFS, and there's nothing we can do about that.
There is no functional change because before we'd just call
forEachNetlinkMessage on an empty Slice, which does nothing.

Also increase the socket buffer to 1MB to reduce the chance of
getting ENOBUFS and thus leaking some mCookieTagMap entries. This
buffer size is equivalent to half the buffer size of a single TCP
socket on LTE.

While we're at it, don't pass POLLRDHUP, POLLERR, and POLLHUP to
poll, since these are ignored in events and are only meaningful
in revents.

Bug: 111479770
Test: netd_{unit,integration}_test pass
Test: builds, boots, cell and wifi work
Test: stress test does not cause infinite loop in netd
Change-Id: I847aeb9a53095c1dfdeddadcd20c0e750b6513ff
parent f4b7b1f6
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment