Skip to content

socketcan: retry send() on ENOBUFS until the timeout expires - #2148

Merged
zariiii9003 merged 1 commit into
hardbyte:mainfrom
DanShinde:socketcan-retry-enobufs
Nov 22, 2026
Merged

zariiii9003 merged 1 commit into
hardbyte:mainfrom
DanShinde:socketcan-retry-enobufs

Conversation

@DanShinde

Copy link
Copy Markdown
Contributor

Summary of Changes

  • SocketcanBus.send() now retries when the socket fails with ENOBUFS (device queue full) while the timeout has not expired, sleeping 1 ms between attempts so it doesn't busy-wait. Without a timeout, or once the timeout has expired, the CanOperationError is raised as before.
  • Other OSErrors are not retried.

epoll reports the socket as writable even when the device queue (qlen) is full, so the existing wait-for-EPOLLOUT loop never helps in this case; this is the approach suggested in the issue, but done in send() so _send_once() keeps its behaviour.

Related Issues / Pull Requests

Type of Change

  • Bug fix

Checklist

  • I have followed the contribution guide.
  • I have added or updated tests as appropriate.
  • I have added or updated documentation as appropriate.
  • I have added a news fragment for towncrier.
  • socketcan tests, black, ruff, pylint and mypy pass locally (full tox left to CI).

Additional Notes

Tests mock the socket, so they run without vcan.

A full device queue can make send() fail with ENOBUFS even though epoll
reports the socket as writable. Wait briefly and retry while the timeout
has not expired, instead of failing right away.

Closes hardbyte#2004

@zariiii9003 zariiii9003 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@zariiii9003
zariiii9003 merged commit 9b51477 into hardbyte:main Nov 22, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bus.send() fails with No buffer space available despite not reaching the timeout

2 participants