X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/de355530ae67247cbd0da700edb3a2a1dae884c2..378393581903b274cb7a4d18e0d978071a6b592d:/bsd/netat/ddp_r_zip.c

diff --git a/bsd/netat/ddp_r_zip.c b/bsd/netat/ddp_r_zip.c
index 12d6aee82..bde37beb8 100644
--- a/bsd/netat/ddp_r_zip.c
+++ b/bsd/netat/ddp_r_zip.c
@@ -89,8 +89,8 @@ extern short	ErrorZIPoverflow;
 static	int	netinfo_reply_pending;
 static	void	zip_netinfo_reply(at_x_zip_t *, at_ifaddr_t *);
 static	void	zip_getnetinfo(at_ifaddr_t *);
-static	void	zip_getnetinfo_funnel(at_ifaddr_t *);
-static	void	send_phony_reply(gbuf_t *);
+static	void	zip_getnetinfo_locked(void *);
+static	void	send_phony_reply(void *);
 
 /*
  * zip_send_getnetinfo_reply: we received a GetNetInfo packet, we need to reply
@@ -742,6 +742,7 @@ void zip_router_input (m, ifID)
 			 */
 			ifID->ifNumRetries = ZIP_NETINFO_RETRIES;
 			netinfo_reply_pending = 1;
+			ifID->ifGNIScheduled = 1;
 			timeout(zip_sched_getnetinfo, (caddr_t) ifID, 
 				 2*ZIP_TIMER_INT);
 	
@@ -881,6 +882,7 @@ static void zip_netinfo_reply (netinfo, ifID)
 		 ifID->ifThisCableStart, ifID->ifThisCableEnd));
 
 	/* The packet is in response to our request */
+	ifID->ifGNIScheduled = 0;
 	untimeout (zip_sched_getnetinfo, (caddr_t) ifID);
 	netinfo_reply_pending = 0;
 	zone_name_len = netinfo->data[0];
@@ -965,13 +967,15 @@ int zip_control (ifID, control)
 	switch (control) {
 	case ZIP_ONLINE :
 	case ZIP_LATE_ROUTER :
-		ifID->ifNumRetries = 0;
-		/* Get the desired zone name from elap and put it in
-		 * ifID for zip_getnetinfo() to use.
-		 */
-		if (ifID->startup_zone.len)
-			ifID->ifZoneName = ifID->startup_zone;
-		zip_getnetinfo(ifID);
+		if (!ifID->ifGNIScheduled) {
+			ifID->ifNumRetries = 0;
+			/* Get the desired zone name from elap and put it in
+		 	* ifID for zip_getnetinfo() to use.
+		 	*/
+			if (ifID->startup_zone.len)
+				ifID->ifZoneName = ifID->startup_zone;
+			zip_getnetinfo(ifID);
+		}
 		break;
 	case ZIP_NO_ROUTER :
 		ifID->ifZoneName.len = 1;
@@ -988,13 +992,19 @@ int zip_control (ifID, control)
 	return (0);
 }
 
-/* funnel version of zip_getnetinfo */
-static void zip_getnetinfo_funnel(ifID)
-     register at_ifaddr_t       *ifID;
+/* locked version of zip_getnetinfo */
+static void zip_getnetinfo_locked(arg)
+     void       *arg;
 {
-        thread_funnel_set(network_flock, TRUE);
-	zip_getnetinfo(ifID);
-        thread_funnel_set(network_flock, FALSE);
+	at_ifaddr_t       *ifID;
+	
+	atalk_lock();
+	if (ifID != NULL) {		// make sure it hasn't been closed
+		ifID = (at_ifaddr_t *)arg;
+		ifID->ifGNIScheduled = 0;
+		zip_getnetinfo(ifID);
+	}
+	atalk_unlock();
 }
 
 
@@ -1011,6 +1021,7 @@ static void zip_getnetinfo (ifID)
 	void			zip_sched_getnetinfo();
 	register struct	atalk_addr	*at_dest;
 	register int		size;
+	
 
 	size =  DDP_X_HDR_SIZE + ZIP_X_HDR_SIZE + ifID->ifZoneName.len + 1
 		+ sizeof(struct atalk_addr) + 1;
@@ -1021,7 +1032,8 @@ static void zip_getnetinfo (ifID)
 		 */
 		dPrintf(D_M_ZIP, D_L_WARNING, ("zip_getnetinfo: no buffer, call later port=%d\n",
 			ifID->ifPort));
-		timeout (zip_getnetinfo_funnel, (caddr_t) ifID, ZIP_TIMER_INT/10);
+		ifID->ifGNIScheduled = 1;
+		timeout (zip_getnetinfo_locked, (caddr_t) ifID, ZIP_TIMER_INT/10);
 		return;
 	}
 
@@ -1074,7 +1086,7 @@ static void zip_getnetinfo (ifID)
 
 	ifID->ifNumRetries++;
 	netinfo_reply_pending = 1;
-
+	ifID->ifGNIScheduled = 1;
 	timeout (zip_sched_getnetinfo, (caddr_t) ifID, ZIP_TIMER_INT);
 } /* zip_getnetinfo */
 
@@ -1087,9 +1099,10 @@ static void zip_getnetinfo (ifID)
 void	zip_sched_getnetinfo (ifID)
      register at_ifaddr_t	     *ifID;
 {
-	boolean_t 	funnel_state;
 
-	funnel_state = thread_funnel_set(network_flock, TRUE);
+	atalk_lock();
+	
+	ifID->ifGNIScheduled = 0;
 
 	if (ifID->ifNumRetries >= ZIP_NETINFO_RETRIES) {
 		/* enough packets sent.... give up! */
@@ -1118,7 +1131,7 @@ void	zip_sched_getnetinfo (ifID)
 	} else
 		zip_getnetinfo(ifID);
 
-	(void) thread_funnel_set(network_flock, FALSE);
+	atalk_unlock();
 }
 
 
@@ -1258,16 +1271,15 @@ int zip_handle_getmyzone(ifID, m)
 }
 
 static	void
-send_phony_reply(rm)
-	gbuf_t	*rm;
+send_phony_reply(arg)
+	void	*arg;
 {
-	boolean_t 	funnel_state;
+	gbuf_t  *rm = (gbuf_t *)arg;
 
-	funnel_state = thread_funnel_set(network_flock, TRUE);
-        
+	atalk_lock();
 	ddp_input(rm, ifID_home);
+	atalk_unlock();
         
-	(void) thread_funnel_set(network_flock, FALSE);
 	return;
 }