The changes in GCC 11.x made `std::condition_variable` implementation
internals `noexcept`. `noexcept` is known to interact particularly bad
with `pthread_cancel`, i.e. `__cxxabiv1::__force_unwind` passing through
the `noexcept` call stack frame causes a `std::terminate` call and
immediate termination of the program
Digging through the GCC ML archives[1] lead me to the idea of patching
this with a few pthread_setcancelstate's. As bad as the solution is, it
seems to be the best we can do within C++17 limits and without major
rework.
[1]: https://gcc.gnu.org/legacy-ml/gcc/2017-08/msg00156.html
Whenever the network module is configured with both "format" and
"format-$state" and when the module use "format-$state" once, it
override the value that was saved from "format".
For example, if both "format" and "format-disconnect" are configured,
and only those, as soon as the module show information about a
disconnected interface, it will keep showing the format for
disconnected, even if the interface is connected again later.
Fix that by always setting a value to default_format_ in update() and
thus use the intended default format when needed.
Fixes#1129
When an interface's state is change to "down", all the route
associated with it are deleted without an RTM_DELROUTE event.
So when this happen, reset the module to start looking for a new
external interface / default route.
Fixes#1117
The check to figure out if we have the default route should be after
the for loop that parses the route attributes, to avoid acting on
incomplete information. We are going to use more fields from the
message.
The module doesn't update the `essid_` as soon as a WiFi interface is
connected, but that happens at some point later, depending on
"interval" configuration.
Fix that by rerunning the get WiFi information thread when the
`carrier` state changes. Also, we will clear the state related to WiFi
when the connection is drop to avoid stale information.
Some RTM_NEWLINK messages may not have the IFLA_CARRIER information.
This is the case when a WiFi interface report scan result are
available. `carrier` is used regardless of if it is present in the
message or not. This would result in the interface appearing
"disconnected" in waybar when it isn't.
This patch now check that `carrier` is available before using it.
The same thing could potentially happen to `ifname` so check if it's
set before recording it.
Fixes: c1427ff (network: Handle carrier information)
Fixes#388
IFLA_CARRIER allows to know when a cable is plugged to the Ethernet
card or when the WiFi is connected. If there's no carrier, the
interface will be considered disconnected.
Last part of the rework of handleEvents(), this time we take the
getExternalInterface() function and add it to the handleEvents()
function. That way, waybar can react immediately when a new "external
interface" is available and doesn't need to probe. Also that avoid to
have two different functions consuming from the same socket and we
don't need to recode some of the functions that are already available
via libnl (to send and receive messages).
In order to get the IP address of an interface, we can get the
information out of NEWADDR events without needed to call getifaddrs().
And when now events are expected, we can requests a dump of all
addresses and handle addresses changes the same way via handleEvents()
only.
Instead of using an alternative way to list all links in order to
choose one when an "interface" is in the configuration, we can ask for
a dump of all interface an reuse the handleEvents() function.
This patch also start to rework the handleEvents() function to grab
more information out of each event, like the interface name.
When more than one message is available to read on the ev_sock_
socket, only the first one is read.
Make some changes to be able to read all the messages available by
setting the socket to non-blocking. This way we can detect when
there's nothing left to read and loop back to wait with epoll.
Fix modules starting with no text, but not hidding.
Start with some "text" in the module's label_, update() will then
update it. Since the text should be different, update() will be able
to show or hide the event_box_. This is to work around the case where
the module start with no text, but the the event_box_ is shown.