~kris/9p

9hist

5307a1cd38d71e1905e8eddab98e2ffe89fce094 — David du Colombier 35 years ago b8f5620
Plan 9 from Bell Labs 1990-11-16
M gnot/dat.h => gnot/dat.h +1 -1
@@ 462,7 462,7 @@ struct Queue {
 *  a stream head
 */
struct Stream {
	Lock;			/* structure lock */
	QLock;			/* structure lock */
	short	inuse;		/* number of processes in stream */
	short	opens;		/* number of processes with stream open */
	ushort	hread;		/* number of reads after hangup */

M gnot/devcons.c => gnot/devcons.c +8 -1
@@ 83,7 83,14 @@ static void	rs232kproc(void*);
static void	rs232open(Queue*, Stream*);
static void	rs232close(Queue*);
static void	rs232oput(Queue*, Block*);
Qinfo rs232info = { nullput, rs232oput, rs232open, rs232close, "rs232" };
Qinfo rs232info =
{
	nullput,
	rs232oput,
	rs232open,
	rs232close,
	"rs232"
};

void
printinit(void)

M gnot/devdk.c => gnot/devdk.c +16 -2
@@ 202,7 202,14 @@ static void dkmuxopen(Queue *, Stream *);
static void dkmuxclose(Queue *);
static void dkmuxoput(Queue *, Block *);
static void dkmuxiput(Queue *, Block *);
Qinfo dkmuxinfo = { dkmuxiput, dkmuxoput, dkmuxopen, dkmuxclose, "dkmux" };
Qinfo dkmuxinfo =
{
	dkmuxiput,
	dkmuxoput,
	dkmuxopen,
	dkmuxclose,
	"dkmux"
};

/*
 *  Look for a dk struct with a name.  If none exists,  create one.


@@ 357,7 364,14 @@ static void dkstopen(Queue *, Stream *);
static void dkstclose(Queue *);
static void dkoput(Queue *, Block *);
static void dkiput(Queue *, Block *);
Qinfo dkinfo = { dkiput, dkoput, dkstopen, dkstclose, "dk" };
Qinfo dkinfo =
{
	dkiput,
	dkoput,
	dkstopen,
	dkstclose,
	"dk"
};

/*
 *  open and save a pointer to the conversation

M gnot/devincon.c => gnot/devincon.c +8 -1
@@ 131,7 131,14 @@ static void inconkproc(void*);
static void inconoput(Queue*, Block*);
static void inconstopen(Queue*, Stream*);
static void inconstclose(Queue*);
Qinfo inconinfo = { nullput, inconoput, inconstopen, inconstclose, "incon" };
Qinfo inconinfo =
{
	nullput,
	inconoput,
	inconstopen,
	inconstclose,
	"incon"
};

int incondebug;


M gnot/devpipe.c => gnot/devpipe.c +1 -1
@@ 178,7 178,7 @@ pipeopen(Chan *c, int omode)
		 *  pointer from the other stream.
		 */
		if(streamenter(local)<0)
			panic("pipeopen");
			panic("pipeattach");
	}
	unlock(p);
	poperror();

M gnot/main.c => gnot/main.c +1 -1
@@ 317,7 317,7 @@ confinit(void)
	conf.nmntbuf = 2*conf.nmntdev;
	conf.nmnthdr = 2*conf.nmntdev;
	conf.nstream = 40 + 16*mul;		/* was 64 */
	conf.nqueue = 4 * conf.nstream;		/* was 5 */
	conf.nqueue = 5 * conf.nstream;
	conf.nblock = 24 * conf.nstream;	/* was 32 */
	conf.nsrv = 16*mul;			/* was 32 */
	conf.nbitmap = 300*mul;

M gnot/stasync.c => gnot/stasync.c +9 -1
@@ 59,7 59,15 @@ static void asyncoput(Queue*, Block*);
static void asyncopen(Queue*, Stream*);
static void asyncclose(Queue*);
static void asyncreset(void);
Qinfo asyncinfo = { asynciput, asyncoput, asyncopen, asyncclose, "async", asyncreset };
Qinfo asyncinfo =
{
	asynciput,
	asyncoput,
	asyncopen,
	asyncclose,
	"async",
	asyncreset
};

int asyncdebug = 0;
int asyncerror;

M gnot/stream.c => gnot/stream.c +41 -36
@@ 16,7 16,14 @@ enum {
 *  process end line discipline
 */
static void stputq(Queue*, Block*);
Qinfo procinfo = { stputq, nullput, 0, 0, "process" };
Qinfo procinfo =
{
	stputq,
	nullput,
	0,
	0,
	"process"
};

/*
 *  line disciplines that can be pushed


@@ 645,10 652,10 @@ streamnew(ushort type, ushort dev, ushort id, Qinfo *qi, int noopen)
	 */
	for(s = slist; s < &slist[conf.nstream]; s++) {
		if(s->inuse == 0){
			if(canlock(s)){
			if(canqlock(s)){
				if(s->inuse == 0)
					break;
				unlock(s);
				qunlock(s);
			}
		}
	}


@@ 657,7 664,7 @@ streamnew(ushort type, ushort dev, ushort id, Qinfo *qi, int noopen)
		error(0, Enostream);
	}
	if(waserror()){
		unlock(s);
		qunlock(s);
		streamclose1(s);
		nexterror();
	}


@@ 690,7 697,7 @@ streamnew(ushort type, ushort dev, ushort id, Qinfo *qi, int noopen)
	if(qi->open)
		(*qi->open)(RD(s->devq), s);

	unlock(s);
	qunlock(s);
	poperror();
	return s;
}


@@ 710,17 717,17 @@ streamopen(Chan *c, Qinfo *qi)
	for(s = slist; s < &slist[conf.nstream]; s++) {
		if(s->inuse && s->type == c->type && s->dev == c->dev
		   && s->id == STREAMID(c->qid)){
			lock(s);
			qlock(s);
			if(s->inuse && s->type == c->type
			&& s->dev == c->dev
		 	&& s->id == STREAMID(c->qid)){
				s->inuse++;
				s->opens++;
				c->stream = s;
				unlock(s);
				qunlock(s);
				return;
			}
			unlock(s);
			qunlock(s);
		}
	}



@@ 737,13 744,13 @@ streamopen(Chan *c, Qinfo *qi)
int
streamenter(Stream *s)
{
	lock(s);
	qlock(s);
	if(s->opens == 0){
		unlock(s);
		qunlock(s);
		return -1;
	}
	s->inuse++;
	unlock(s);
	qunlock(s);
	return 0;
}



@@ 760,10 767,10 @@ streamexit(Stream *s, int locked)
	char *name;

	if(!locked)
		lock(s);
		qlock(s);
	if(s->inuse == 1){
		if(s->opens != 0)
			print("streamexit %d %s\n", s->opens, s->devq->info->name);
			panic("streamexit %d %s\n", s->opens, s->devq->info->name);

		/*
		 *  ascend the stream freeing the queues


@@ 777,7 784,7 @@ streamexit(Stream *s, int locked)
	s->inuse--;
	rv = s->inuse;
	if(!locked)
		unlock(s);
		qunlock(s);
	return rv;
}



@@ 794,33 801,33 @@ streamclose1(Stream *s)
	/*
	 *  decrement the reference count
	 */
	lock(s);
	qlock(s);
	if(s->opens == 1){
		if(!waserror()){
			/*
			 *  descend the stream closing the queues
			 */
			for(q = s->procq; q; q = q->next){
		/*
		 *  descend the stream closing the queues
		 */
		for(q = s->procq; q; q = q->next){
			if(!waserror()){
				if(q->info->close)
					(*q->info->close)(q->other);
				WR(q)->put = nullput;

				/*
				 *  this may be 2 streams joined device end to device end
				 */
				if(q == s->devq->other)
					break;
			}
			poperror();

			/*
			 *  this may be 2 streams joined device end to device end
			 */
			if(q == s->devq->other)
				break;
		}
	}
	
		/*
		 *  ascend the stream flushing the queues
		 */
		for(q = s->devq; q; q = nq){
			nq = q->next;
			flushq(q);
		}
	/*
	 *  ascend the stream flushing the queues
	 */
	for(q = s->devq; q; q = nq){
		nq = q->next;
		flushq(q);
	}
	s->opens--;



@@ 828,7 835,7 @@ streamclose1(Stream *s)
	 *  leave it and free it
	 */
	streamexit(s, 1);
	unlock(s);
	qunlock(s);
}
void
streamclose(Chan *c)


@@ 1006,8 1013,6 @@ streamread(Chan *c, void *vbuf, long n)
 *	hangup			-- send an M_HANGUP up the stream
 *	push ldname		-- push the line discipline named ldname
 *	pop			-- pop a line discipline
 *
 *  This routing is entrered with s->wrlock'ed and must unlock.
 */
static long
streamctlwrite(Chan *c, void *a, long n)

M gnot/sturp.c => gnot/sturp.c +9 -1
@@ 120,7 120,15 @@ static void	urpkproc(void *arg);
static void	urptimer(Alarm*);
static void	urpvomit(char*, Urp*);

Qinfo urpinfo = { urpciput, urpoput, urpopen, urpclose, "urp", urpreset };
Qinfo urpinfo =
{
	urpciput,
	urpoput,
	urpopen,
	urpclose,
	"urp",
	urpreset
};

static void
urpreset(void)

M port/stasync.c => port/stasync.c +9 -1
@@ 59,7 59,15 @@ static void asyncoput(Queue*, Block*);
static void asyncopen(Queue*, Stream*);
static void asyncclose(Queue*);
static void asyncreset(void);
Qinfo asyncinfo = { asynciput, asyncoput, asyncopen, asyncclose, "async", asyncreset };
Qinfo asyncinfo =
{
	asynciput,
	asyncoput,
	asyncopen,
	asyncclose,
	"async",
	asyncreset
};

int asyncdebug = 0;
int asyncerror;

M port/stream.c => port/stream.c +9 -2
@@ 16,7 16,14 @@ enum {
 *  process end line discipline
 */
static void stputq(Queue*, Block*);
Qinfo procinfo = { stputq, nullput, 0, 0, "process" };
Qinfo procinfo =
{
	stputq,
	nullput,
	0,
	0,
	"process"
};

/*
 *  line disciplines that can be pushed


@@ 763,7 770,7 @@ streamexit(Stream *s, int locked)
		lock(s);
	if(s->inuse == 1){
		if(s->opens != 0)
			print("streamexit %d %s\n", s->opens, s->devq->info->name);
			panic("streamexit %d %s\n", s->opens, s->devq->info->name);

		/*
		 *  ascend the stream freeing the queues

M port/sturp.c => port/sturp.c +9 -1
@@ 120,7 120,15 @@ static void	urpkproc(void *arg);
static void	urptimer(Alarm*);
static void	urpvomit(char*, Urp*);

Qinfo urpinfo = { urpciput, urpoput, urpopen, urpclose, "urp", urpreset };
Qinfo urpinfo =
{
	urpciput,
	urpoput,
	urpopen,
	urpclose,
	"urp",
	urpreset
};

static void
urpreset(void)

M power/devhs.c => power/devhs.c +8 -1
@@ 88,7 88,14 @@ static void hsvmekproc(void*);
static void hsvmeoput(Queue*, Block*);
static void hsvmestopen(Queue*, Stream*);
static void hsvmestclose(Queue*);
Qinfo hsvmeinfo = { nullput, hsvmeoput, hsvmestopen, hsvmestclose, "hsvme" };
Qinfo hsvmeinfo =
{
	nullput,
	hsvmeoput,
	hsvmestopen,
	hsvmestclose,
	"hsvme"
};

/*
 *  restart a VME board

M power/main.c => power/main.c +1 -1
@@ 610,7 610,7 @@ confinit(void)
	conf.nenv = 15*conf.nproc;
	conf.nenvchar = 20 * conf.nenv;
	conf.npte = 4 * conf.npage;
	conf.nqueue = 3 * conf.nstream;
	conf.nqueue = 5 * conf.nstream;
	conf.nblock = 10 * conf.nstream;
	conf.npipe = conf.nstream/2;