OpenCyphal / pycyphal

Python implementation of the Cyphal protocol stack.
https://pycyphal.readthedocs.io/
MIT License
120 stars 105 forks source link

Avoid ENOBUFS OSErrors by shrinking the size of SNDBUF when appropriate. #234

Closed wiboticalex closed 2 years ago

wiboticalex commented 2 years ago

This is a followup to issue #233.

Avoid ENOBUFS OSErrors by shrinking the size of SNDBUF when appropriate.

Similar behavior could have probably been achieved by simply setting the socket's SNDBUF to 0 to get whatever Linux sets as the minimum, but it seems like this may cause potential queue under-utilization when there are large queues specified, so this pull request tries to calculate (with a very rough approximation for sk_buffer struct size) what the minimum SNDBUF should be to get blocking behavior.

pavel-kirienko commented 2 years ago

@wiboticalex can you please run Black to fix the formatting? This should get merged automatically afterward.

wiboticalex commented 2 years ago

Done. Thought I could get away with moving code around and not reformatting, but apparently not :slightly_smiling_face: .

Thanks @pavel-kirienko