Commit 68a52b85 authored by Teng Qin's avatar Teng Qin

Don't close epoll FD if it's already closed

parent 5440af33
......@@ -136,12 +136,14 @@ StatusTuple BPFPerfBuffer::close_all_cpu() {
std::string errors;
bool has_error = false;
int close_res = close(epfd_);
epfd_ = -1;
ep_events_.reset();
if (close_res != 0) {
has_error = true;
errors += std::string(std::strerror(errno)) + "\n";
if (epfd_ >= 0) {
int close_res = close(epfd_);
epfd_ = -1;
ep_events_.reset();
if (close_res != 0) {
has_error = true;
errors += std::string(std::strerror(errno)) + "\n";
}
}
std::vector<int> opened_cpus;
......
......@@ -244,7 +244,7 @@ void perf_reader_event_read(struct perf_reader *reader) {
if (reader->lost_cb) {
reader->lost_cb(lost);
} else {
fprintf(stderr, "Possibly lost " PRIu64 " samples\n", lost);
fprintf(stderr, "Possibly lost %" PRIu64 " samples\n", lost);
}
} else if (e->type == PERF_RECORD_SAMPLE) {
if (reader->type == PERF_TYPE_TRACEPOINT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment