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 #517 (net_io_counters on Solaris 10) #680

Merged
merged 4 commits into from
Sep 6, 2015
Merged

Conversation

wiggin15
Copy link
Collaborator

@wiggin15 wiggin15 commented Sep 6, 2015

During kstat enumeration in net_io_counters on Solaris, we check for class=net and module=link to find kstats for network interfaces. As reported in #517 (example kstat output is submitted there), module is not always 'link' so on Solaris 10 we don't find any interfaces.
net_if_stats does the same enumeration but there is no problem there because it doesn't check the module, and instead sends a ioctl and decides if the current stat name is a network interface name according to the result. I copied the same logic from there to net_io_counters.
Also fixed 2 minor bugs along the way that would only happen in error cases.

The second commit is modelled after parts of the patch in #517 but also fixes the data types passed to Py_BuildValue.

Arnon Yaari added 3 commits September 6, 2015 11:02
instead of testing ksp->ks_module is 'link'
and not system dependent

_INT64_TYPE may be defined but kstat may still return
the IO counters in 32-bit types.
In addition, on SunOS, sizeof(long)==sizeof(long long)==8
so using 'k' and 'K' means the same, and we need to ue 'I' for
unsigned 32 bit integers.
@@ -7,6 +7,7 @@ Bug tracker at https://github.com/giampaolo/psutil/issues

- #677: [Linux] can't install psutil due to bug in setup.py.
- #610: [SunOS] fix build and tests on Solaris 10
- #517: [SunOS] fix net_io_counters on Solaris 10
Copy link
Owner

Choose a reason for hiding this comment

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

please be more specific (describe what issue is being addressed)

@giampaolo
Copy link
Owner

Does this fix #517?

@@ -685,25 +688,30 @@ psutil_net_io_counters(PyObject *self, PyObject *args) {
if (kc == NULL)
goto error;

sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == -1)
goto error;
Copy link
Owner

Choose a reason for hiding this comment

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

You need to PyErr_SetFromErrno(PyExc_OSError) before goto error;.

@wiggin15
Copy link
Collaborator Author

wiggin15 commented Sep 6, 2015

Yes, it does.
I fixed what you wrote in the comments. Thanks.

giampaolo added a commit that referenced this pull request Sep 6, 2015
Fix #517 (net_io_counters on Solaris 10)
@giampaolo giampaolo merged commit 41550ff into giampaolo:master Sep 6, 2015
@giampaolo
Copy link
Owner

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants