From 08bfdda4cb303ff6c8562914a2b76a285ecffe49 Mon Sep 17 00:00:00 2001 From: Alexis Date: Sat, 24 Nov 2018 16:01:22 +0100 Subject: [PATCH] revert(network): wait interface --- src/modules/network.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/modules/network.cpp b/src/modules/network.cpp index cf100b4b..c73ed00e 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -52,7 +52,6 @@ void waybar::modules::Network::worker() return; } bool need_update = false; - bool new_addr = false; for (auto nh = reinterpret_cast(buf); NLMSG_OK(nh, len); nh = NLMSG_NEXT(nh, len)) { if (nh->nlmsg_type == NLMSG_DONE) { @@ -61,9 +60,6 @@ void waybar::modules::Network::worker() if (nh->nlmsg_type == NLMSG_ERROR) { continue; } - if (nh->nlmsg_type == RTM_NEWADDR) { - new_addr = true; - } if (nh->nlmsg_type < RTM_NEWADDR) { auto rtif = static_cast(NLMSG_DATA(nh)); if (rtif->ifi_index == static_cast(ifid_)) { @@ -75,15 +71,9 @@ void waybar::modules::Network::worker() } } if (ifid_ <= 0 && !config_["interface"].isString()) { - if (new_addr) { - // Need to wait before get external interface - while (ifid_ <= 0) { - ifid_ = getExternalInterface(); - thread_.sleep_for(std::chrono::seconds(1)); - } - } else { - ifid_ = getExternalInterface(); - } + // Need to wait before get external interface + thread_.sleep_for(std::chrono::seconds(1)); + ifid_ = getExternalInterface(); if (ifid_ > 0) { char ifname[IF_NAMESIZE]; if_indextoname(ifid_, ifname);