Skip to content

Add process specific open file descriptor limits#2225

Merged
dbwiddis merged 7 commits into
oshi:masterfrom
gitseti:process-specific-open-file-limits
Oct 30, 2022
Merged

Add process specific open file descriptor limits#2225
dbwiddis merged 7 commits into
oshi:masterfrom
gitseti:process-specific-open-file-limits

Conversation

@gitseti

@gitseti gitseti commented Oct 26, 2022

Copy link
Copy Markdown
Contributor

This resolves #2215 as it implements the second needed part.

@gitseti gitseti force-pushed the process-specific-open-file-limits branch from 402c06c to e708de8 Compare October 26, 2022 08:24
@sonatype-lift

sonatype-lift Bot commented Oct 26, 2022

Copy link
Copy Markdown
Contributor

⚠️ 26 God Classes were detected by Lift in this project. Visit the Lift web console for more details.

@gitseti gitseti force-pushed the process-specific-open-file-limits branch 2 times, most recently from 7d625ae to 98c2af6 Compare October 26, 2022 08:33
@gitseti gitseti force-pushed the process-specific-open-file-limits branch from 98c2af6 to a36fff9 Compare October 26, 2022 08:43
@Override
public long getHardOpenFileLimit() {
final Resource.Rlimit rlimit = new Resource.Rlimit();
OpenBsdLibc.INSTANCE.getrlimit(OpenBsdLibc.RLIMIT_NOFILE, rlimit);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💬 15 similar findings have been found in this PR


INTERFACE_NOT_THREAD_SAFE: Unprotected call to method OpenBsdLibc.getrlimit(...) of un-annotated interface oshi.jna.platform.unix.OpenBsdLibc. Consider annotating the interface with @ThreadSafe or adding a lock.
Reporting because the current class is annotated @ThreadSafe.


🔎 Expand here to view all instances of this finding
File Path Line Number
oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java 275
oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java 287
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java 282
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java 264
oshi-core/src/main/java/oshi/software/os/mac/MacOSProcess.java 316
oshi-core/src/main/java/oshi/software/os/mac/MacOSProcess.java 328
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSProcess.java 269
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java 270
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java 276
oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdOSProcess.java 311

Showing 10 of 15 findings. Visit the Lift Web Console to see all.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Comment thread oshi-core/src/main/java/oshi/software/os/OSProcess.java Outdated
this.majorVersion = major;
this.minorVersion = minor;
this.os = os;
updateAttributes();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💬 15 similar findings have been found in this PR


INTERFACE_NOT_THREAD_SAFE: Unprotected call to method SystemB.getgrgid(...) of un-annotated interface com.sun.jna.platform.mac.SystemB. Consider annotating the interface with @ThreadSafe or adding a lock.
Reporting because the current class is annotated @ThreadSafe.


🔎 Expand here to view all instances of this finding
File Path Line Number
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java 270
oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java 179
oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdOSProcess.java 313
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java 281
oshi-core/src/main/java/oshi/software/os/mac/MacOSProcess.java 327
oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSProcess.java 252
oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdOSProcess.java 324
oshi-core/src/main/java/oshi/software/os/mac/MacOSProcess.java 316
oshi-core/src/main/java/oshi/software/os/linux/LinuxOSProcess.java 99
oshi-core/src/main/java/oshi/software/os/mac/MacOperatingSystem.java 174

Showing 10 of 15 findings. Visit the Lift Web Console to see all.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@dbwiddis

Copy link
Copy Markdown
Member

Hey @gitseti don't want to rush this PR, but based on a bug report in AIX I'm probably going to try to push out a patch release this weekend. Do you want me to try to wait for you to finish this implementation or is it close enough to release it as-is with some more tweaks for the next version?

@gitseti

gitseti commented Oct 29, 2022

Copy link
Copy Markdown
Contributor Author

Hey @dbwiddis, imo, it should be ready for review now.

The only thing left would be to have a solution for Windows as I'm not sure how to do the _getmaxstdio JNA call.
Currently, we just use the getMaxFileDescriptorsPerProcess returned limits for getSoftOpenFileLimit and getHardOpenFileLimit on Windows. We can also deliver the more precise limits for Windows in a later patch.
WDYT?

@gitseti gitseti marked this pull request as ready for review October 29, 2022 19:55
@dbwiddis dbwiddis added the hacktoberfest Issues we're happy for new #Hacktoberfest2020 participants to do label Oct 30, 2022
@dbwiddis

Copy link
Copy Markdown
Member

We can table the windows _getmaxstdio question. I think it actually only applies to the Windows C runtime so would be inaccurate for other processes. I replaced your call navigating the API to get to a constant with a direct fetching of the constant (which happens to be in a class in the same package). Will merge shortly.

Thanks again for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest Issues we're happy for new #Hacktoberfest2020 participants to do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add max file descriptors per process

2 participants