Skip to content

Fixed some resource leaks leading to a "too many open files" error #1465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 23, 2021

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Sep 23, 2021

  • Please check if the PR fulfills these requirements
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • The PR follows our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?
    This PR fixes two resource leaks pipe in the PluggableDiscovery client, in particular:
  1. a leaked pair of pipes in the discovery.New command: the Process creation was done at object init time and the StdinPipe and StdOutpipe methods actually create an OS pipe even if the process is not started later.
  2. a leaked pair of pipes when the discovery process terminates: we didn't call the Wait method to collect the resources used by the zombie process.

Moved the process creation at the very last moment, since StdInPipe and
StdOutPipe methods actually creates a OS pipe even if the process is not
started later.
Otherwise the resources allocated by the process will be leaked.
(pipes, zombie process, etc.)
@cmaglie cmaglie merged commit 71ce1a4 into arduino:master Sep 23, 2021
@cmaglie cmaglie deleted the fix_pipes_leak branch September 23, 2021 14:06
@cmaglie cmaglie added the type: imperfection Perceived defect in any part of project label Sep 23, 2021
@cmaglie cmaglie self-assigned this Sep 23, 2021
@cmaglie cmaglie changed the title Fix pipes leak Fixed some resource leaks leading to a "too many open files" error (#1465) Sep 23, 2021
@cmaglie cmaglie changed the title Fixed some resource leaks leading to a "too many open files" error (#1465) Fixed some resource leaks leading to a "too many open files" error Sep 23, 2021
silvanocerza added a commit that referenced this pull request Sep 24, 2021
…1465)

* Fixed leaking pipes in Discovery command creation

Moved the process creation at the very last moment, since StdInPipe and
StdOutPipe methods actually create an OS pipe even if the process is not
started later.

* When a discovery is quitted ensure that the process gets Wait-ed

Otherwise, the resources allocated by the process will be leaked.
(pipes, zombie process, etc.)

* fix i18n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants