From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Track references of batman_if in set_primary_if
Date: Sat, 18 Sep 2010 17:23:00 +0200 [thread overview]
Message-ID: <1284823381-26943-1-git-send-email-sven.eckelmann@gmx.de> (raw)
In-Reply-To: <201009181721.44244.sven.eckelmann@gmx.de>
set_primary_if exchanges the current primary interfaces with a new one.
This is a new reference and thus we have to count it and decrease the
count of the old primary interface.
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
I would like to keep that order of hold -> exchange -> put for later
changes (rcu or something like that for primary_if and curr_gw).
batman-adv/hard-interface.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/batman-adv/hard-interface.c b/batman-adv/hard-interface.c
index f519b4b..942a44a 100644
--- a/batman-adv/hard-interface.c
+++ b/batman-adv/hard-interface.c
@@ -113,9 +113,17 @@ static void set_primary_if(struct bat_priv *bat_priv,
{
struct batman_packet *batman_packet;
struct vis_packet *vis_packet;
+ struct batman_if *old_if;
+ if (batman_if)
+ hardif_hold(batman_if);
+
+ old_if = bat_priv->primary_if;
bat_priv->primary_if = batman_if;
+ if (old_if)
+ hardif_put(old_if);
+
if (!bat_priv->primary_if)
return;
--
1.7.2.3
next prev parent reply other threads:[~2010-09-18 15:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-17 15:40 [B.A.T.M.A.N.] [PATCHv2 0/9] RCU locking patches Sven Eckelmann
2010-09-17 15:40 ` [B.A.T.M.A.N.] [PATCH 1/9] batman-adv: Introduce if_list_lock to protect if_list Sven Eckelmann
2010-09-17 15:40 ` [B.A.T.M.A.N.] [PATCH 2/9] batman-adv: Protect update side of gw_list Sven Eckelmann
2010-09-17 15:40 ` [B.A.T.M.A.N.] [PATCH 3/9] batman-adv: Always protect list_for_each_entry_rcu with RCU Sven Eckelmann
2010-09-17 15:41 ` [B.A.T.M.A.N.] [PATCH 4/9] batman-adv: Remove unneeded rcu_read_lock Sven Eckelmann
2010-09-17 15:41 ` [B.A.T.M.A.N.] [PATCH 5/9] batman-adv: Use synchronize_rcu instead of call_rcu Sven Eckelmann
2010-09-17 15:41 ` [B.A.T.M.A.N.] [PATCH 6/9] batman-adv: Use refcnt to track usage count of gw_node Sven Eckelmann
2010-09-17 15:41 ` [B.A.T.M.A.N.] [PATCH 7/9] batman-adv: Use refcnt to track usage count of batman_if Sven Eckelmann
2010-09-17 15:41 ` [B.A.T.M.A.N.] [PATCH 8/9] batman-adv: count election of gateway as reference Sven Eckelmann
2010-09-17 15:41 ` [B.A.T.M.A.N.] [PATCH 9/9] batman-adv: count batman_if list queries " Sven Eckelmann
2010-09-17 17:27 ` [B.A.T.M.A.N.] [PATCHv2 " Sven Eckelmann
2010-09-18 14:42 ` Marek Lindner
2010-09-18 14:42 ` [B.A.T.M.A.N.] [PATCH] " Marek Lindner
2010-09-18 15:21 ` [B.A.T.M.A.N.] [PATCHv2 9/9] " Sven Eckelmann
2010-09-18 15:23 ` Sven Eckelmann [this message]
2010-09-18 15:23 ` [B.A.T.M.A.N.] [PATCH 2/2] Introduce update_primary_addr to update mac address Sven Eckelmann
2010-09-18 15:41 ` [B.A.T.M.A.N.] [PATCHv2 9/9] batman-adv: count batman_if list queries as reference Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1284823381-26943-1-git-send-email-sven.eckelmann@gmx.de \
--to=sven.eckelmann@gmx.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).