Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/port/tcptimer.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname port/tcptimer.c 1991/0424
## diff -e /dev/null /n/bootesdump/1991/0424/sys/src/9/port/tcptimer.c
0a

#include	"u.h"
#include	"lib.h"
#include	"mem.h"
#include	"dat.h"
#include	"fns.h"
#include	"errno.h"
#include 	"arp.h"
#include 	"ipdat.h"

/* Head of running timer chain */
Timer 	*timers;
QLock 	timerlock;
Rendez	Tcpack;
Rendez	tcpflowr;

void
tcpackproc(void *junk)
{
	Timer *t,*tp;
	Timer *expired;

	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;
			if(tp == t)
				panic("Timer loop at %lux\n",(long)tp);
	
 			if(t->state == TIMER_RUN && --(t->count) == 0){

				/* 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;

				t->state = TIMER_EXPIRE;
				/* Put on head of expired timer list */
				t->next = expired;
				expired = t;
			}
		}
		qunlock(&timerlock);

		while((t = expired) != 0){
			expired = t->next;
			if(t->state == TIMER_EXPIRE && t->func)
				(*t->func)(t->arg);
		}

		tsleep(&Tcpack, return0, 0, MSPTICK);
	}
}

void
start_timer(Timer *t)
{

	if(t == 0 || t->start == 0)
		return;

	qlock(&timerlock);

	t->count = t->start;
	if(t->state != TIMER_RUN){
		t->state = TIMER_RUN;
		/* Put on head of active timer list */
		t->prev = 0;
		t->next = timers;
		if(t->next != 0)
			t->next->prev = t;
		timers = t;
	}
	qunlock(&timerlock);
}

void
stop_timer(Timer *t)
{
	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;
	}
	t->state = TIMER_STOP;

	qunlock(&timerlock);
}

void
tcpflow(void *conv)
{
	Ipconv *base, *ifc, *etab;

	base = (Ipconv*)conv;

	etab = &base[conf.ip];
	for(;;) {
		sleep(&tcpflowr, return0, 0);

		for(ifc = base; ifc < etab; ifc++) {
			if(ifc->stproto == &tcpinfo &&
			   ifc->ref != 0 && ifc->readq &&
			   !QFULL(ifc->readq->next)) {
				tcprcvwin(ifc);
				tcp_acktimer(ifc);
			}
		}
	}
}

.
## diffname port/tcptimer.c 1991/1115
## diff -e /n/bootesdump/1991/0424/sys/src/9/port/tcptimer.c /n/bootesdump/1991/1115/sys/src/9/port/tcptimer.c
21a
	USED(junk);
.
## diffname port/tcptimer.c 1992/0111
## diff -e /n/bootesdump/1991/1115/sys/src/9/port/tcptimer.c /n/bootesdump/1992/0111/sys/src/9/port/tcptimer.c
6c
#include	"../port/error.h"
.
## diffname port/tcptimer.c 1992/0128
## diff -e /n/bootesdump/1992/0111/sys/src/9/port/tcptimer.c /n/bootesdump/1992/0128/sys/src/9/port/tcptimer.c
1c
#include	"u.h"
.
## diffname port/tcptimer.c 1992/0314
## diff -e /n/bootesdump/1992/0128/sys/src/9/port/tcptimer.c /n/bootesdump/1992/0314/sys/src/9/port/tcptimer.c
121,123c
			if(ifc->readq)
			if(ifc->ref != 0)
			if(ifc->stproto == &tcpinfo)
			if(!QFULL(ifc->readq->next)) {
.
57c
			if(t->state == TIMER_EXPIRE)
			if(t->func)
.
55c
		for(;;) {
			t = expired;
			if(t == 0)
				break;

.
37c
 			if(t->state == TIMER_RUN)
			if(--(t->count) == 0){
.
26,30d
## diffname port/tcptimer.c 1992/0321
## diff -e /n/bootesdump/1992/0314/sys/src/9/port/tcptimer.c /n/bootesdump/1992/0321/sys/src/9/port/tcptimer.c
2c
#include	"../port/lib.h"
.
## diffname port/tcptimer.c 1992/0626
## diff -e /n/bootesdump/1992/0321/sys/src/9/port/tcptimer.c /n/bootesdump/1992/0626/sys/src/9/port/tcptimer.c
121,127c
		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);
.
115,117c
	ifc = x;
	etab = &ifc->conv[Nipconv];
.
113c
	Ipifc *ifc;
	Ipconv *cp, **p, **etab;
.
111c
tcpflow(void *x)
.
## diffname port/tcptimer.c 1992/0807
## diff -e /n/bootesdump/1992/0626/sys/src/9/port/tcptimer.c /n/bootesdump/1992/0807/sys/src/9/port/tcptimer.c
125,127c
			if(cp->readq && cp->ref != 0 && !QFULL(cp->readq->next)) {
.
117a

.
## diffname port/tcptimer.c 1992/0903
## diff -e /n/bootesdump/1992/0807/sys/src/9/port/tcptimer.c /n/bootesdump/1992/0903/sys/src/9/port/tcptimer.c
109,133d
106,107c
	qunlock(&tl);
.
94,104c
	qlock(&tl);
	if(t->state == TIMER_RUN)
		deltimer(t);
.
89c
tcphalt(Timer *t)
.
85c
	qunlock(&tl);
.
81c
		if(t->next)
.
78d
76c
	if(t->state != TIMER_RUN) {
.
73,74c
	qlock(&tl);
.
69d
67c
tcpgo(Timer *t)
.
61d
49c
		qunlock(&tl);
.
44d
34,42c
				deltimer(t);
.
29,31d
26c
		qlock(&tl);
.
16a
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
.
15a
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
 */

.
10,13c
static	Timer 	*timers;	/* List of active timers */
static	QLock 	tl;		/* Protect timer list */
static	Rendez	Tcpack;
.
## diffname port/tcptimer.c 1992/0906
## diff -e /n/bootesdump/1992/0903/sys/src/9/port/tcptimer.c /n/bootesdump/1992/0906/sys/src/9/port/tcptimer.c
122c
	t->state = TimerOFF;
.
120c
	if(t->state == TimerON)
.
102,103c
	if(t->state != TimerON) {
		t->state = TimerON;
.
85,86c
			timeo = t->next;
			if(t->state == TimerDONE)
.
81c
			t = timeo;
.
70,75c
 			if(t->state == TimerON) {
				t->count--;
				if(t->count == 0) {
					deltimer(t);
					t->state = TimerDONE;
					t->next = timeo;
					timeo = t;
				}
.
65c
		timeo = 0;
.
60,61c
	Timer *t, *tp, *timeo;
.
## diffname port/tcptimer.c 1993/0804 # deleted
## diff -e /n/bootesdump/1992/0906/sys/src/9/port/tcptimer.c /n/fornaxdump/1993/0804/sys/src/brazil/port/tcptimer.c
1,125d

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.