patch-2.0.35 linux/net/netrom/nr_timer.c

Next file: linux/net/netrom/sysctl_net_netrom.c
Previous file: linux/net/netrom/nr_subr.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.34/linux/net/netrom/nr_timer.c linux/net/netrom/nr_timer.c
@@ -1,8 +1,5 @@
 /*
- *	NET/ROM release 003
- *
- *	This is ALPHA test software. This code may break your machine, randomly fail to work with new 
- *	releases, misbehave and/or generally screw up. It might even work. 
+ *	NET/ROM release 006
  *
  *	This code REQUIRES 1.2.1 or higher/ NET3.029
  *
@@ -17,7 +14,7 @@
  */
 
 #include <linux/config.h>
-#ifdef CONFIG_NETROM
+#if defined(CONFIG_NETROM) || defined(CONFIG_NETROM_MODULE)
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
@@ -43,51 +40,34 @@
 static void nr_timer(unsigned long);
 
 /*
- *	Linux set/reset timer routines
+ *	Linux set timer
  */
 void nr_set_timer(struct sock *sk)
 {
 	unsigned long flags;
-	
-	save_flags(flags);
-	cli();
-	del_timer(&sk->timer);
-	restore_flags(flags);
-
-	sk->timer.next     = sk->timer.prev = NULL;	
-	sk->timer.data     = (unsigned long)sk;
-	sk->timer.function = &nr_timer;
 
-	sk->timer.expires = jiffies+10;
-	add_timer(&sk->timer);
-}
-
-static void nr_reset_timer(struct sock *sk)
-{
-	unsigned long flags;
-	
-	save_flags(flags);
-	cli();
+	save_flags(flags); cli();
 	del_timer(&sk->timer);
 	restore_flags(flags);
 
 	sk->timer.data     = (unsigned long)sk;
 	sk->timer.function = &nr_timer;
 	sk->timer.expires  = jiffies+10;
+
 	add_timer(&sk->timer);
 }
 
 /*
  *	NET/ROM TIMER 
  *
- *	This routine is called every 500ms. Decrement timer by this
+ *	This routine is called every 100ms. Decrement timer by this
  *	amount - if expired then process the event.
  */
 static void nr_timer(unsigned long param)
 {
 	struct sock *sk = (struct sock *)param;
 
-	switch (sk->nr->state) {
+	switch (sk->protinfo.nr->state) {
 		case NR_STATE_0:
 			/* Magic here: If we listen() and a new link dies before it
 			   is accepted() it isn't 'dead' so doesn't get removed. */
@@ -102,11 +82,11 @@
 			/*
 			 * Check for the state of the receive buffer.
 			 */
-			if (sk->rmem_alloc < (sk->rcvbuf / 2) && (sk->nr->condition & OWN_RX_BUSY_CONDITION)) {
-				sk->nr->condition &= ~OWN_RX_BUSY_CONDITION;
+			if (sk->rmem_alloc < (sk->rcvbuf / 2) && (sk->protinfo.nr->condition & NR_COND_OWN_RX_BUSY)) {
+				sk->protinfo.nr->condition &= ~NR_COND_OWN_RX_BUSY;
+				sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING;
+				sk->protinfo.nr->vl         = sk->protinfo.nr->vr;
 				nr_write_internal(sk, NR_INFOACK);
-				sk->nr->condition &= ~ACK_PENDING_CONDITION;
-				sk->nr->vl = sk->nr->vr;
 				break;
 			}
 			/*
@@ -119,72 +99,75 @@
 			break;
 	}
 
-	if (sk->nr->t2timer > 0 && --sk->nr->t2timer == 0) {
-		if (sk->nr->state == NR_STATE_3) {
-			if (sk->nr->condition & ACK_PENDING_CONDITION) {
-				sk->nr->condition &= ~ACK_PENDING_CONDITION;
+	if (sk->protinfo.nr->t2timer > 0 && --sk->protinfo.nr->t2timer == 0) {
+		if (sk->protinfo.nr->state == NR_STATE_3) {
+			if (sk->protinfo.nr->condition & NR_COND_ACK_PENDING) {
+				sk->protinfo.nr->condition &= ~NR_COND_ACK_PENDING;
 				nr_enquiry_response(sk);
 			}
 		}
 	}
 
-	if (sk->nr->t4timer > 0 && --sk->nr->t4timer == 0) {
-		sk->nr->condition &= ~PEER_RX_BUSY_CONDITION;
+	if (sk->protinfo.nr->t4timer > 0 && --sk->protinfo.nr->t4timer == 0) {
+		sk->protinfo.nr->condition &= ~NR_COND_PEER_RX_BUSY;
 	}
 
-	if (sk->nr->t1timer == 0 || --sk->nr->t1timer > 0) {
-		nr_reset_timer(sk);
+	if (sk->protinfo.nr->t1timer == 0 || --sk->protinfo.nr->t1timer > 0) {
+		nr_set_timer(sk);
 		return;
 	}
 
-	switch (sk->nr->state) {
+	switch (sk->protinfo.nr->state) {
 		case NR_STATE_1: 
-			if (sk->nr->n2count == sk->nr->n2) {
+			if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) {
 				nr_clear_queues(sk);
-				sk->nr->state = NR_STATE_0;
-				sk->state     = TCP_CLOSE;
-				sk->err       = ETIMEDOUT;
+				sk->protinfo.nr->state = NR_STATE_0;
+				sk->state              = TCP_CLOSE;
+				sk->err                = ETIMEDOUT;
+				sk->shutdown          |= SEND_SHUTDOWN;
 				if (!sk->dead)
 					sk->state_change(sk);
-				sk->dead      = 1;
+				sk->dead               = 1;
 			} else {
-				sk->nr->n2count++;
+				sk->protinfo.nr->n2count++;
 				nr_write_internal(sk, NR_CONNREQ);
 			}
 			break;
 
 		case NR_STATE_2:
-			if (sk->nr->n2count == sk->nr->n2) {
+			if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) {
 				nr_clear_queues(sk);
-				sk->nr->state = NR_STATE_0;
-				sk->state     = TCP_CLOSE;
-				sk->err       = ETIMEDOUT;
+				sk->protinfo.nr->state = NR_STATE_0;
+				sk->state              = TCP_CLOSE;
+				sk->err                = ETIMEDOUT;
+				sk->shutdown          |= SEND_SHUTDOWN;
 				if (!sk->dead)
 					sk->state_change(sk);
-				sk->dead      = 1;
+				sk->dead               = 1;
 			} else {
-				sk->nr->n2count++;
+				sk->protinfo.nr->n2count++;
 				nr_write_internal(sk, NR_DISCREQ);
 			}
 			break;
 
 		case NR_STATE_3:
-			if (sk->nr->n2count == sk->nr->n2) {
+			if (sk->protinfo.nr->n2count == sk->protinfo.nr->n2) {
 				nr_clear_queues(sk);
-				sk->nr->state = NR_STATE_0;
-				sk->state     = TCP_CLOSE;
-				sk->err       = ETIMEDOUT;
+				sk->protinfo.nr->state = NR_STATE_0;
+				sk->state              = TCP_CLOSE;
+				sk->err                = ETIMEDOUT;
+				sk->shutdown          |= SEND_SHUTDOWN;
 				if (!sk->dead)
 					sk->state_change(sk);
-				sk->dead      = 1;
+				sk->dead               = 1;
 			} else {
-				sk->nr->n2count++;
+				sk->protinfo.nr->n2count++;
 				nr_requeue_frames(sk);
 			}
 			break;
 	}
 
-	sk->nr->t1timer = sk->nr->t1 = nr_calculate_t1(sk);
+	sk->protinfo.nr->t1timer = sk->protinfo.nr->t1;
 
 	nr_set_timer(sk);
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov