From 04717a6f1b9442db0e19309fd0ca22e96857622d Mon Sep 17 00:00:00 2001 From: wwmm Date: Tue, 10 Sep 2024 12:24:05 -0300 Subject: [PATCH] netlink: improved event handling --- src/netlink.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/netlink.cpp b/src/netlink.cpp index 7f9e73f..da2cbec 100644 --- a/src/netlink.cpp +++ b/src/netlink.cpp @@ -80,12 +80,14 @@ void Netlink::subscribe() const { } void Netlink::handle_events() { - std::vector buff(getpagesize()); + // std::vector buff(getpagesize()); + char buff[4096]; sockaddr_nl addr{}; iovec iov[1]; - iov[0].iov_base = buff.data(); - iov[0].iov_len = sizeof(char) * buff.size(); + iov[0].iov_base = buff; + // iov[0].iov_len = sizeof(char) * buff.size(); + iov[0].iov_len = sizeof(buff); msghdr msg_hdr{.msg_name = &addr, .msg_namelen = sizeof(addr), @@ -112,7 +114,8 @@ void Netlink::handle_events() { continue; } - auto* nlmsg_hdr = reinterpret_cast(buff.data()); + // auto* nlmsg_hdr = reinterpret_cast(buff.data()); + auto* nlmsg_hdr = reinterpret_cast(buff); while (NLMSG_OK(nlmsg_hdr, len)) { if (!std::filesystem::is_regular_file(input_file)) {