revert(network): wait interface

pull/105/head
Alexis 2018-11-24 16:01:22 +01:00
parent 8f8ec3b999
commit 08bfdda4cb
1 changed files with 3 additions and 13 deletions

View File

@ -52,7 +52,6 @@ void waybar::modules::Network::worker()
return;
}
bool need_update = false;
bool new_addr = false;
for (auto nh = reinterpret_cast<struct nlmsghdr *>(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<struct ifinfomsg *>(NLMSG_DATA(nh));
if (rtif->ifi_index == static_cast<int>(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);