-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
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 |
There was a problem hiding this comment.
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)
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; |
There was a problem hiding this comment.
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;
.
Yes, it does. |
Fix #517 (net_io_counters on Solaris 10)
Thank you! |
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.