Skip to content
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

fix #2639: getOwningProcessId sometimes return -1 on 64x linux #2645

Merged
merged 1 commit into from
May 25, 2024

Conversation

yourancc
Copy link
Contributor

@yourancc yourancc commented May 23, 2024

fix the issue(#2639 ) where the owning process ID sometimes returns -1 caused by it.

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

One fix needed. Also please submit a change log entry!

You can just push a new commit to your branch and it will update this PR.

conns.addAll(queryConnections("tcp", 4, pidMap));
conns.addAll(queryConnections("tcp", 6, pidMap));
conns.addAll(queryConnections("udp", 4, pidMap));
conns.addAll(queryConnections("udp", 6, pidMap));
return conns;
}

private static List<IPConnection> queryConnections(String protocol, int ipver, Map<Integer, Integer> pidMap) {
private static List<IPConnection> queryConnections(String protocol, int ipver, Map<Long, Integer> pidMap) {
Copy link
Member

Choose a reason for hiding this comment

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

You need to parse the inode a few lines down to a long to match this key.

Copy link

codecov bot commented May 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.20%. Comparing base (9bc64f4) to head (b0a48e0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2645      +/-   ##
==========================================
- Coverage   86.24%   85.20%   -1.05%     
==========================================
  Files          30       30              
  Lines        1338     1338              
  Branches      189      189              
==========================================
- Hits         1154     1140      -14     
- Misses        103      116      +13     
- Partials       81       82       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yourancc
Copy link
Contributor Author

Thank you for your feedback. I have made the necessary changes to the code.

socklen_t is an unsigned (native) long which is 32-bit or 64-bit depending on OS bitness.
Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Almost there!

CHANGELOG.md Outdated
@@ -7,6 +7,7 @@
[#2625](https://github.com/oshi/oshi/pull/2625): Add part number to Physical Memory - [@BartekDziurowicz](https://github.com/BartekDziurowicz), [@dbwiddis](https://github.com/dbwiddis).

##### Bug fixes / Improvements
* [#2645](https://github.com/oshi/oshi/pull/2645): fix getOwningProcessId sometimes return -1 on 64x linux - [@yourancc](https://github.com/yourancc).
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be under the new 6.6.1 section

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution to open source!

@yourancc
Copy link
Contributor Author

thank you for your patient guidance

@dbwiddis dbwiddis merged commit cad9125 into oshi:master May 25, 2024
15 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.

LinuxInternetProtocolStats IPConnection invoke getOwningProcessId always return -1
2 participants