summaryrefslogtreecommitdiff
path: root/src/network/networkd-netdev.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-05-08 20:42:22 +0200
committerTom Gundersen <teg@jklm.no>2014-05-09 14:41:27 +0200
commit2cc7e981af27b12a6a3d4f08728281febeb450c9 (patch)
tree627edd0fc7bff18f5d993d44043fcfb405e09b5c /src/network/networkd-netdev.c
parent59cb64e6253e445c78b9e78be5e27bae0015ea38 (diff)
networkd: netdev - introduce LINGER state and netdev_drop()
We need the LINGER state in case we still have references to the netdev after it has been dropped.
Diffstat (limited to 'src/network/networkd-netdev.c')
-rw-r--r--src/network/networkd-netdev.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index ed4bc191f3..c7bec74aa3 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -108,6 +108,19 @@ NetDev *netdev_ref(NetDev *netdev) {
return netdev;
}
+void netdev_drop(NetDev *netdev) {
+ if (!netdev || netdev->state == NETDEV_STATE_LINGER)
+ return;
+
+ netdev->state = NETDEV_STATE_LINGER;
+
+ netdev_cancel_callbacks(netdev);
+
+ netdev_unref(netdev);
+
+ return;
+}
+
int netdev_get(Manager *manager, const char *name, NetDev **ret) {
NetDev *netdev;