patch-2.4.0-test2 linux/net/ipv4/igmp.c

Next file: linux/net/ipv4/ipconfig.c
Previous file: linux/net/ipv4/icmp.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test1/linux/net/ipv4/igmp.c linux/net/ipv4/igmp.c
@@ -8,7 +8,7 @@
  *	the older version didn't come out right using gcc 2.5.8, the newer one
  *	seems to fall out with gcc 2.6.2.
  *
- *	Version: $Id: igmp.c,v 1.38 2000/02/27 01:20:02 davem Exp $
+ *	Version: $Id: igmp.c,v 1.39 2000/06/21 17:17:32 davem Exp $
  *
  *	Authors:
  *		Alan Cox <Alan.Cox@linux.org>
@@ -150,15 +150,14 @@
 	spin_unlock_bh(&im->lock);
 }
 
-static __inline__ void igmp_start_timer(struct ip_mc_list *im, int max_delay)
+/* It must be called with locked im->lock */
+static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
 {
 	int tv=net_random() % max_delay;
 
-	spin_lock_bh(&im->lock);
 	im->tm_running=1;
 	if (!mod_timer(&im->timer, jiffies+tv+2))
 		atomic_inc(&im->refcnt);
-	spin_unlock_bh(&im->lock);
 }
 
 static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)
@@ -174,9 +173,8 @@
 		}
 		atomic_dec(&im->refcnt);
 	}
-	spin_unlock_bh(&im->lock);
-
 	igmp_start_timer(im, max_delay);
+	spin_unlock_bh(&im->lock);
 }
 
 
@@ -259,6 +257,7 @@
 	struct in_device *in_dev = im->interface;
 	int err;
 
+	spin_lock(&im->lock);
 	im->tm_running=0;
 
 	if (IGMP_V1_SEEN(in_dev))
@@ -270,8 +269,7 @@
 	if (err) {
 		if (!in_dev->dead)
 			igmp_start_timer(im, IGMP_Unsolicited_Report_Interval);
-		ip_ma_put(im);
-		return;
+		goto out;
 	}
 
 	if (im->unsolicit_count) {
@@ -279,6 +277,8 @@
 		igmp_start_timer(im, IGMP_Unsolicited_Report_Interval);
 	}
 	im->reporter = 1;
+out:
+	spin_unlock(&im->lock);
 	ip_ma_put(im);
 }
 
@@ -455,7 +455,9 @@
 	if (im->multiaddr == IGMP_ALL_HOSTS)
 		return;
 
+	spin_lock_bh(&im->lock);
 	igmp_start_timer(im, IGMP_Initial_Report_Delay);
+	spin_unlock_bh(&im->lock);
 #endif
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)