plan 9 kernel history: overview | file list | diff list

1992/0128/port/tcptimer.c (diff list | history)

1991/0424/sys/src/9/port/tcptimer.c:19,241991/1115/sys/src/9/port/tcptimer.c:19,25 (short | long)
1991/0424    
	Timer *t,*tp; 
	Timer *expired; 
 
1991/1115    
	USED(junk); 
1991/0424    
	for(;;) { 
		expired = 0; 
 
1991/1115/sys/src/9/port/tcptimer.c:3,91992/0111/sys/src/9/port/tcptimer.c:3,9 (short | long)
Move error.h to ../port. Change errors to actual strings.
rsc Fri Mar 4 12:44:25 2005
1991/0424    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
#include	"errno.h" 
1992/0111    
#include	"../port/error.h" 
1991/0424    
#include 	"arp.h" 
#include 	"ipdat.h" 
 
1992/0111/sys/src/9/port/tcptimer.c:1,41992/0128/sys/src/9/port/tcptimer.c:1,4 (short | long)
1991/0424    

#include	"u.h" 
1992/0128    
#include	"u.h" 
1991/0424    
#include	"lib.h" 
#include	"mem.h" 
#include	"dat.h" 
1992/0128/sys/src/9/port/tcptimer.c:23,331992/0314/sys/src/9/port/tcptimer.c:23,28 (short | long)
1991/0424    
	for(;;) { 
		expired = 0; 
 
		/* Run through the list of running timers, decrementing each one. 
		 * If one has expired, take it off the running list and put it 
		 * on a singly linked list of expired timers 
		 */ 
                 
		qlock(&timerlock); 
		for(t = timers;t != 0; t = tp) { 
			tp = t->next; 
1992/0128/sys/src/9/port/tcptimer.c:34,401992/0314/sys/src/9/port/tcptimer.c:29,36
1991/0424    
			if(tp == t) 
				panic("Timer loop at %lux\n",(long)tp); 
	 
 			if(t->state == TIMER_RUN && --(t->count) == 0){ 
1992/0314    
 			if(t->state == TIMER_RUN) 
			if(--(t->count) == 0){ 
1991/0424    
 
				/* Delete from active timer list */ 
				if(timers == t) 
1992/0128/sys/src/9/port/tcptimer.c:52,601992/0314/sys/src/9/port/tcptimer.c:48,61
1991/0424    
		} 
		qunlock(&timerlock); 
 
		while((t = expired) != 0){ 
1992/0314    
		for(;;) { 
			t = expired; 
			if(t == 0) 
				break; 
 
1991/0424    
			expired = t->next; 
			if(t->state == TIMER_EXPIRE && t->func) 
1992/0314    
			if(t->state == TIMER_EXPIRE) 
			if(t->func) 
1991/0424    
				(*t->func)(t->arg); 
		} 
 
1992/0128/sys/src/9/port/tcptimer.c:118,1261992/0314/sys/src/9/port/tcptimer.c:119,128
1991/0424    
		sleep(&tcpflowr, return0, 0); 
 
		for(ifc = base; ifc < etab; ifc++) { 
			if(ifc->stproto == &tcpinfo && 
			   ifc->ref != 0 && ifc->readq && 
			   !QFULL(ifc->readq->next)) { 
1992/0314    
			if(ifc->readq) 
			if(ifc->ref != 0) 
			if(ifc->stproto == &tcpinfo) 
			if(!QFULL(ifc->readq->next)) { 
1991/0424    
				tcprcvwin(ifc); 
				tcp_acktimer(ifc); 
			} 
1992/0314/sys/src/9/port/tcptimer.c:1,51992/0321/sys/src/9/port/tcptimer.c:1,5 (short | long)
Move lib.h to ../port.
rsc Fri Mar 4 12:44:25 2005
1992/0128    
#include	"u.h" 
1991/0424    
#include	"lib.h" 
1992/0321    
#include	"../port/lib.h" 
1991/0424    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
1992/0321/sys/src/9/port/tcptimer.c:108,1301992/0626/sys/src/9/port/tcptimer.c:108,132 (short | long)
1991/0424    
} 
 
void 
tcpflow(void *conv) 
1992/0626    
tcpflow(void *x) 
1991/0424    
{ 
	Ipconv *base, *ifc, *etab; 
1992/0626    
	Ipifc *ifc; 
	Ipconv *cp, **p, **etab; 
1991/0424    
 
	base = (Ipconv*)conv; 
                 
	etab = &base[conf.ip]; 
1992/0626    
	ifc = x; 
	etab = &ifc->conv[Nipconv]; 
1991/0424    
	for(;;) { 
		sleep(&tcpflowr, return0, 0); 
 
		for(ifc = base; ifc < etab; ifc++) { 
1992/0314    
			if(ifc->readq) 
			if(ifc->ref != 0) 
			if(ifc->stproto == &tcpinfo) 
			if(!QFULL(ifc->readq->next)) { 
1991/0424    
				tcprcvwin(ifc); 
				tcp_acktimer(ifc); 
1992/0626    
		for(p = ifc->conv; p < etab; p++) { 
			cp = *p; 
			if(cp == 0) 
				break; 
			if(cp->readq) 
			if(cp->ref != 0) 
			if(!QFULL(cp->readq->next)) { 
				tcprcvwin(cp); 
				tcp_acktimer(cp); 
1991/0424    
			} 
		} 
	} 
1992/0626/sys/src/9/port/tcptimer.c:115,1201992/0807/sys/src/9/port/tcptimer.c:115,121 (short | long)
1991/0424    
 
1992/0626    
	ifc = x; 
	etab = &ifc->conv[Nipconv]; 
1992/0807    
 
1991/0424    
	for(;;) { 
		sleep(&tcpflowr, return0, 0); 
 
1992/0626/sys/src/9/port/tcptimer.c:122,1301992/0807/sys/src/9/port/tcptimer.c:123,129
1992/0626    
			cp = *p; 
			if(cp == 0) 
				break; 
			if(cp->readq) 
			if(cp->ref != 0) 
			if(!QFULL(cp->readq->next)) { 
1992/0807    
			if(cp->readq && cp->ref != 0 && !QFULL(cp->readq->next)) { 
1992/0626    
				tcprcvwin(cp); 
				tcp_acktimer(cp); 
1991/0424    
			} 
1992/0807/sys/src/9/port/tcptimer.c:7,191992/0903/sys/src/9/port/tcptimer.c:7,60 (short | long)
1991/0424    
#include 	"arp.h" 
#include 	"ipdat.h" 
 
/* Head of running timer chain */ 
Timer 	*timers; 
QLock 	timerlock; 
Rendez	Tcpack; 
1992/0903    
static	Timer 	*timers;	/* List of active timers */ 
static	QLock 	tl;		/* Protect timer list */ 
static	Rendez	Tcpack; 
1991/0424    
Rendez	tcpflowr; 
 
1992/0903    
static void 
deltimer(Timer *t) 
{ 
	if(timers == t) 
		timers = t->next; 
 
	if(t->next) 
		t->next->prev = t->prev; 
 
	if(t->prev) 
		t->prev->next = t->next; 
} 
 
/* 
 * Poke each tcp connection to recompute window size and 
 * acknowledgement timer 
 */ 
 
1991/0424    
void 
1992/0903    
tcpflow(void *x) 
{ 
	Ipifc *ifc; 
	Ipconv *cp, **p, **etab; 
 
	ifc = x; 
	etab = &ifc->conv[Nipconv]; 
 
	for(;;) { 
		sleep(&tcpflowr, return0, 0); 
 
		for(p = ifc->conv; p < etab; p++) { 
			cp = *p; 
			if(cp == 0) 
				break; 
			if(cp->readq && cp->ref != 0 && !QFULL(cp->readq->next)) { 
				tcprcvwin(cp); 
				tcpacktimer(cp); 
			} 
		} 
	} 
} 
 
void 
1991/0424    
tcpackproc(void *junk) 
{ 
	Timer *t,*tp; 
1992/0807/sys/src/9/port/tcptimer.c:23,521992/0903/sys/src/9/port/tcptimer.c:64,81
1991/0424    
	for(;;) { 
		expired = 0; 
 
		qlock(&timerlock); 
1992/0903    
		qlock(&tl); 
1991/0424    
		for(t = timers;t != 0; t = tp) { 
			tp = t->next; 
			if(tp == t) 
				panic("Timer loop at %lux\n",(long)tp); 
	                 
1992/0314    
 			if(t->state == TIMER_RUN) 
			if(--(t->count) == 0){ 
1991/0424    
                 
				/* Delete from active timer list */ 
				if(timers == t) 
					timers = t->next; 
				if(t->next != 0) 
					t->next->prev = t->prev; 
				if(t->prev != 0) 
					t->prev->next = t->next; 
                 
1992/0903    
				deltimer(t); 
1991/0424    
				t->state = TIMER_EXPIRE; 
				/* Put on head of expired timer list */ 
				t->next = expired; 
				expired = t; 
			} 
		} 
		qunlock(&timerlock); 
1992/0903    
		qunlock(&tl); 
1991/0424    
 
1992/0314    
		for(;;) { 
			t = expired; 
1992/0807/sys/src/9/port/tcptimer.c:58,1331992/0903/sys/src/9/port/tcptimer.c:87,124
1992/0314    
			if(t->func) 
1991/0424    
				(*t->func)(t->arg); 
		} 
                 
		tsleep(&Tcpack, return0, 0, MSPTICK); 
	} 
} 
 
void 
start_timer(Timer *t) 
1992/0903    
tcpgo(Timer *t) 
1991/0424    
{ 
                 
	if(t == 0 || t->start == 0) 
		return; 
 
	qlock(&timerlock); 
                 
1992/0903    
	qlock(&tl); 
1991/0424    
	t->count = t->start; 
	if(t->state != TIMER_RUN){ 
1992/0903    
	if(t->state != TIMER_RUN) { 
1991/0424    
		t->state = TIMER_RUN; 
		/* Put on head of active timer list */ 
		t->prev = 0; 
		t->next = timers; 
		if(t->next != 0) 
1992/0903    
		if(t->next) 
1991/0424    
			t->next->prev = t; 
		timers = t; 
	} 
	qunlock(&timerlock); 
1992/0903    
	qunlock(&tl); 
1991/0424    
} 
 
void 
stop_timer(Timer *t) 
1992/0903    
tcphalt(Timer *t) 
1991/0424    
{ 
	if(t == 0) 
		return; 
 
	qlock(&timerlock); 
                 
	if(t->state == TIMER_RUN){ 
		/* Delete from active timer list */ 
		if(timers == t) 
			timers = t->next; 
		if(t->next != 0) 
			t->next->prev = t->prev; 
		if(t->prev != 0) 
			t->prev->next = t->next; 
	} 
1992/0903    
	qlock(&tl); 
	if(t->state == TIMER_RUN) 
		deltimer(t); 
1991/0424    
	t->state = TIMER_STOP; 
                 
	qunlock(&timerlock); 
1992/0903    
	qunlock(&tl); 
1991/0424    
} 
                 
void 
1992/0626    
tcpflow(void *x) 
1991/0424    
{ 
1992/0626    
	Ipifc *ifc; 
	Ipconv *cp, **p, **etab; 
1991/0424    
                 
1992/0626    
	ifc = x; 
	etab = &ifc->conv[Nipconv]; 
1992/0807    
                 
1991/0424    
	for(;;) { 
		sleep(&tcpflowr, return0, 0); 
                 
1992/0626    
		for(p = ifc->conv; p < etab; p++) { 
			cp = *p; 
			if(cp == 0) 
				break; 
1992/0807    
			if(cp->readq && cp->ref != 0 && !QFULL(cp->readq->next)) { 
1992/0626    
				tcprcvwin(cp); 
				tcp_acktimer(cp); 
1991/0424    
			} 
		} 
	} 
} 
                 
1992/0903/sys/src/9/port/tcptimer.c:57,891992/0906/sys/src/9/port/tcptimer.c:57,90 (short | long)
1992/0903    
void 
1991/0424    
tcpackproc(void *junk) 
{ 
	Timer *t,*tp; 
	Timer *expired; 
1992/0906    
	Timer *t, *tp, *timeo; 
1991/0424    
 
1991/1115    
	USED(junk); 
1991/0424    
	for(;;) { 
		expired = 0; 
1992/0906    
		timeo = 0; 
1991/0424    
 
1992/0903    
		qlock(&tl); 
1991/0424    
		for(t = timers;t != 0; t = tp) { 
			tp = t->next; 
1992/0314    
 			if(t->state == TIMER_RUN) 
			if(--(t->count) == 0){ 
1992/0903    
				deltimer(t); 
1991/0424    
				t->state = TIMER_EXPIRE; 
				t->next = expired; 
				expired = t; 
1992/0906    
 			if(t->state == TimerON) { 
				t->count--; 
				if(t->count == 0) { 
					deltimer(t); 
					t->state = TimerDONE; 
					t->next = timeo; 
					timeo = t; 
				} 
1991/0424    
			} 
		} 
1992/0903    
		qunlock(&tl); 
1991/0424    
 
1992/0314    
		for(;;) { 
			t = expired; 
1992/0906    
			t = timeo; 
1992/0314    
			if(t == 0) 
				break; 
 
1991/0424    
			expired = t->next; 
1992/0314    
			if(t->state == TIMER_EXPIRE) 
1992/0906    
			timeo = t->next; 
			if(t->state == TimerDONE) 
1992/0314    
			if(t->func) 
1991/0424    
				(*t->func)(t->arg); 
		} 
1992/0903/sys/src/9/port/tcptimer.c:99,1061992/0906/sys/src/9/port/tcptimer.c:100,107
1991/0424    
 
1992/0903    
	qlock(&tl); 
1991/0424    
	t->count = t->start; 
1992/0903    
	if(t->state != TIMER_RUN) { 
1991/0424    
		t->state = TIMER_RUN; 
1992/0906    
	if(t->state != TimerON) { 
		t->state = TimerON; 
1991/0424    
		t->prev = 0; 
		t->next = timers; 
1992/0903    
		if(t->next) 
1992/0903/sys/src/9/port/tcptimer.c:117,1241992/0906/sys/src/9/port/tcptimer.c:118,125
1991/0424    
		return; 
 
1992/0903    
	qlock(&tl); 
	if(t->state == TIMER_RUN) 
1992/0906    
	if(t->state == TimerON) 
1992/0903    
		deltimer(t); 
1991/0424    
	t->state = TIMER_STOP; 
1992/0906    
	t->state = TimerOFF; 
1992/0903    
	qunlock(&tl); 
1991/0424    
} 
1992/0906/sys/src/9/port/tcptimer.c:1,1251993/0804/sys/src/9/port/tcptimer.c:0 (short | long)
Deleted.
rsc Mon Mar 7 10:32:26 2005
1992/0128    
#include	"u.h" 
1992/0321    
#include	"../port/lib.h" 
1991/0424    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
1992/0111    
#include	"../port/error.h" 
1991/0424    
#include 	"arp.h" 
#include 	"ipdat.h" 
                 
1992/0903    
static	Timer 	*timers;	/* List of active timers */ 
static	QLock 	tl;		/* Protect timer list */ 
static	Rendez	Tcpack; 
1991/0424    
Rendez	tcpflowr; 
                 
1992/0903    
static void 
deltimer(Timer *t) 
{ 
	if(timers == t) 
		timers = t->next; 
                 
	if(t->next) 
		t->next->prev = t->prev; 
                 
	if(t->prev) 
		t->prev->next = t->next; 
} 
                 
/* 
 * Poke each tcp connection to recompute window size and 
 * acknowledgement timer 
 */ 
                 
1991/0424    
void 
1992/0903    
tcpflow(void *x) 
{ 
	Ipifc *ifc; 
	Ipconv *cp, **p, **etab; 
                 
	ifc = x; 
	etab = &ifc->conv[Nipconv]; 
                 
	for(;;) { 
		sleep(&tcpflowr, return0, 0); 
                 
		for(p = ifc->conv; p < etab; p++) { 
			cp = *p; 
			if(cp == 0) 
				break; 
			if(cp->readq && cp->ref != 0 && !QFULL(cp->readq->next)) { 
				tcprcvwin(cp); 
				tcpacktimer(cp); 
			} 
		} 
	} 
} 
                 
void 
1991/0424    
tcpackproc(void *junk) 
{ 
1992/0906    
	Timer *t, *tp, *timeo; 
1991/0424    
                 
1991/1115    
	USED(junk); 
1991/0424    
	for(;;) { 
1992/0906    
		timeo = 0; 
1991/0424    
                 
1992/0903    
		qlock(&tl); 
1991/0424    
		for(t = timers;t != 0; t = tp) { 
			tp = t->next; 
1992/0906    
 			if(t->state == TimerON) { 
				t->count--; 
				if(t->count == 0) { 
					deltimer(t); 
					t->state = TimerDONE; 
					t->next = timeo; 
					timeo = t; 
				} 
1991/0424    
			} 
		} 
1992/0903    
		qunlock(&tl); 
1991/0424    
                 
1992/0314    
		for(;;) { 
1992/0906    
			t = timeo; 
1992/0314    
			if(t == 0) 
				break; 
                 
1992/0906    
			timeo = t->next; 
			if(t->state == TimerDONE) 
1992/0314    
			if(t->func) 
1991/0424    
				(*t->func)(t->arg); 
		} 
		tsleep(&Tcpack, return0, 0, MSPTICK); 
	} 
} 
                 
void 
1992/0903    
tcpgo(Timer *t) 
1991/0424    
{ 
	if(t == 0 || t->start == 0) 
		return; 
                 
1992/0903    
	qlock(&tl); 
1991/0424    
	t->count = t->start; 
1992/0906    
	if(t->state != TimerON) { 
		t->state = TimerON; 
1991/0424    
		t->prev = 0; 
		t->next = timers; 
1992/0903    
		if(t->next) 
1991/0424    
			t->next->prev = t; 
		timers = t; 
	} 
1992/0903    
	qunlock(&tl); 
1991/0424    
} 
                 
void 
1992/0903    
tcphalt(Timer *t) 
1991/0424    
{ 
	if(t == 0) 
		return; 
                 
1992/0903    
	qlock(&tl); 
1992/0906    
	if(t->state == TimerON) 
1992/0903    
		deltimer(t); 
1992/0906    
	t->state = TimerOFF; 
1992/0903    
	qunlock(&tl); 
1991/0424    
} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)