Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: third_party/psutil/psutil/_psutil_osx.c

Issue 8774018: Add psutil build step to fix pyauto media issues. Upgrade psutil to 0.4.0. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Disable Mac builds. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/psutil/psutil/_psutil_osx.c
diff --git a/third_party/psutil/psutil/_psutil_osx.c b/third_party/psutil/psutil/_psutil_osx.c
index 29162f20b6f757eef9e692a2b8dfa83cc4c3a7a7..7edc5cadd30cd652e22a8a2a92dba9a93dbd0786 100644
--- a/third_party/psutil/psutil/_psutil_osx.c
+++ b/third_party/psutil/psutil/_psutil_osx.c
@@ -1,5 +1,5 @@
/*
- * $Id: _psutil_osx.c 1142 2011-10-05 18:45:49Z g.rodola $
+ * $Id: _psutil_osx.c 1193 2011-10-22 18:24:53Z g.rodola@gmail.com $
*
* Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
@@ -69,8 +69,8 @@ get_pid_list(PyObject* self, PyObject* args)
Py_XDECREF(pid);
proclist++;
}
+ free(orig_address);
}
- free(orig_address);
return retlist;
}
@@ -918,13 +918,19 @@ get_process_connections(PyObject* self, PyObject* args)
struct proc_fdinfo *fdp_pointer;
struct socket_fdinfo si;
-
PyObject *retList = PyList_New(0);
PyObject *tuple = NULL;
PyObject *laddr = NULL;
PyObject *raddr = NULL;
+ PyObject *af_filter = NULL;
+ PyObject *type_filter = NULL;
- if (! PyArg_ParseTuple(args, "l", &pid)) {
+ if (! PyArg_ParseTuple(args, "lOO", &pid, &af_filter, &type_filter)) {
+ return NULL;
+ }
+
+ if (!PySequence_Check(af_filter) || !PySequence_Check(type_filter)) {
+ PyErr_SetString(PyExc_TypeError, "arg 2 or 3 is not a sequence");
return NULL;
}
@@ -982,15 +988,12 @@ get_process_connections(PyObject* self, PyObject* args)
int fd, family, type, lport, rport;
char lip[200], rip[200];
char *state;
+ int inseq;
fd = (int)fdp_pointer->proc_fd;
family = si.psi.soi_family;
type = si.psi.soi_kind;
- if ((family != AF_INET) && (family != AF_INET6)) {
- continue;
- }
-
if (type == 2)
type = SOCK_STREAM;
else if (type == 1)
@@ -998,12 +1001,18 @@ get_process_connections(PyObject* self, PyObject* args)
else
continue;
+ // apply filters
+ inseq = PySequence_Contains(af_filter, PyLong_FromLong((long)family));
+ if (inseq == 0)
+ continue;
+ inseq = PySequence_Contains(type_filter, PyLong_FromLong((long)type));
+ if (inseq == 0)
+ continue;
+
if (errno != 0) {
- printf("errno 1 = %i\n", errno);
return PyErr_SetFromErrno(PyExc_OSError);
}
-
if (family == AF_INET) {
inet_ntop(AF_INET,
&si.psi.soi_proto.pri_tcp.tcpsi_ini.insi_laddr.ina_46.i46a_addr4,
@@ -1267,10 +1276,12 @@ get_disk_io_counters(PyObject* self, PyObject* args)
CFNumberGetValue(number, kCFNumberSInt64Type, &write_time);
}
+ // Read/Write time on OS X comes back in nanoseconds and in psutil
+ // we've standardized on milliseconds so do the conversion.
py_disk_info = Py_BuildValue("(KKKKKK)",
reads, writes,
read_bytes, write_bytes,
- read_time, write_time);
+ read_time / 1000, write_time / 1000);
PyDict_SetItemString(py_retdict, disk_name, py_disk_info);
Py_XDECREF(py_disk_info);

Powered by Google App Engine
This is Rietveld 408576698