mirror of
https://github.com/varun-r-mallya/pylibbpf.git
synced 2025-12-31 20:36:26 +00:00
Make lost_callback type asfe in PerfEventArray
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
PerfEventArray::PerfEventArray(std::shared_ptr<BpfMap> map, int page_cnt,
|
||||
py::function callback, py::object lost_callback)
|
||||
: map_(map), pb_(nullptr), callback_(std::move(callback)),
|
||||
lost_callback_(lost_callback) {
|
||||
lost_callback_(std::move(lost_callback)) {
|
||||
|
||||
if (map->get_type() != BPF_MAP_TYPE_PERF_EVENT_ARRAY) {
|
||||
throw BpfException("Map '" + map->get_name() +
|
||||
@ -92,10 +92,12 @@ void PerfEventArray::lost_callback_wrapper(void *ctx, int cpu,
|
||||
py::gil_scoped_acquire acquire;
|
||||
|
||||
try {
|
||||
if (self->lost_callback_.is_none()) {
|
||||
return;
|
||||
if (!self->lost_callback_.is_none()) {
|
||||
py::function lost_fn = py::cast<py::function>(self->lost_callback_);
|
||||
lost_fn(cpu, cnt);
|
||||
} else {
|
||||
py::print("Lost", cnt, "events on CPU", cpu);
|
||||
}
|
||||
self->lost_callback_(cpu, cnt);
|
||||
} catch (const py::error_already_set &e) {
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ private:
|
||||
std::shared_ptr<BpfMap> map_;
|
||||
struct perf_buffer *pb_;
|
||||
py::function callback_;
|
||||
py::function lost_callback_;
|
||||
py::object lost_callback_;
|
||||
|
||||
std::shared_ptr<StructParser> parser_;
|
||||
std::string struct_name_;
|
||||
|
||||
Reference in New Issue
Block a user