~kris/9p

9hist

b57154864d9fe20bfac1269630e57a30736288ae — David du Colombier 35 years ago 36c043e
Plan 9 from Bell Labs 1990-09-30
5 files changed, 49 insertions(+), 47 deletions(-)

M gnot/stream.c
M gnot/sturp.c
M port/stream.c
M port/sturp.c
M power/devhs.c
M gnot/stream.c => gnot/stream.c +4 -1
@@ 905,7 905,10 @@ streamctlread(Chan *c, void *vbuf, long n)
static int
isinput(void *x)
{
	return ((Queue *)x)->first != 0;
	Queue *q;

	q = (Queue *)x;
	return (q->flag&QHUNGUP) || q->first!=0;
}

/*

M gnot/sturp.c => gnot/sturp.c +2 -2
@@ 653,7 653,7 @@ output(Urp *up)
		 */
		up->rexmit = 0;
		up->next = up->unacked;
	} else if(up->unacked!=up->next && NOW>up->timer){
	} else if(up->unechoed!=up->next && NOW>up->timer){
		/*
		 *  if a retransmit time has elapsed since a transmit,
		 *  send an ENQ


@@ 944,7 944,7 @@ todo(void *arg)

	return (up->state&INITING)
	? NOW>up->timer					/* time to INIT1 */
	: ((up->unacked!=up->next && NOW>up->timer)	/* time to ENQ */
	: ((up->unechoed!=up->next && NOW>up->timer)	/* time to ENQ */
	  || WINDOW(up)>0 && up->next!=up->nxb
	  || (!QFULL(up->rq->next) && up->iseq!=(up->lastecho&7))); /* time to ECHO */
}

M port/stream.c => port/stream.c +40 -41
@@ 127,7 127,7 @@ allocb(ulong size)
		;

	/*
	 *  look for a free block, garbage collect if there are none
	 *  look for a free block
	 */
	lock(bcp);
	while(bcp->first == 0){


@@ 878,12 878,37 @@ stringread(Chan *c, uchar *buf, long n, char *str)
}

/*
 *  return the stream id
 */
long
streamctlread(Chan *c, void *vbuf, long n)
{
	uchar *buf = vbuf;
	char num[32];
	Stream *s;

	s = c->stream;
	if(STREAMTYPE(c->qid) == Sctlqid){
		sprint(num, "%d", s->id);
		return stringread(c, buf, n, num);
	} else {
		if(CHDIR & c->qid)
			return devdirread(c, vbuf, n, 0, 0, streamgen);
		else
			panic("streamctlread");
	}
}

/*
 *  return true if there is an output buffer available
 */
static int
isinput(void *x)
{
	return ((Queue *)x)->first != 0;
	Queue *q;

	q = (Queue *)x;
	return (q->flag&QHUNGUP) || q->first!=0;
}

/*


@@ 895,28 920,16 @@ streamread(Chan *c, void *vbuf, long n)
	Block *bp;
	Stream *s;
	Queue *q;
	long rv = 0;
	int left, i, x;
	int left, i;
	uchar *buf = vbuf;
	char num[32];

	s = c->stream;
	switch(STREAMTYPE(c->qid)){
	case Sdataqid:
		break;
	case Sctlqid:
		sprint(num, "%d", s->id);
		return stringread(c, buf, n, num);
	default:
		if(CHDIR & c->qid)
			return devdirread(c, vbuf, n, 0, 0, streamgen);
		else
			panic("streamread");
	}
	if(STREAMTYPE(c->qid) != Sdataqid)
		return streamctlread(c, vbuf, n);

	/*
	 *  one reader at a time
	 */
	s = c->stream;
	qlock(&s->rdlock);
	if(waserror()){
		qunlock(&s->rdlock);


@@ 974,10 987,15 @@ streamread(Chan *c, void *vbuf, long n)
 *  This routing is entrered with s->wrlock'ed and must unlock.
 */
static long
streamctlwrite(Stream *s, void *a, long n)
streamctlwrite(Chan *c, void *a, long n)
{
	Qinfo *qi;
	Block *bp;
	Stream *s;

	if(STREAMTYPE(c->qid) != Sctlqid)
		panic("streamctlwrite %lux", c->qid);
	s = c->stream;

	/*
	 *  package


@@ 1038,26 1056,10 @@ streamwrite(Chan *c, void *a, long n, int docopy)
	s = c->stream;

	/*
	 *  one writer at a time
	qlock(&s->wrlock);
	if(waserror()){
		qunlock(&s->wrlock);
		nexterror();
	}
	 */

	/*
	 *  decode the qid
	 */
	switch(STREAMTYPE(c->qid)){
	case Sdataqid:
		break;
	case Sctlqid:
		n = streamctlwrite(s, a, n);
		goto out;
	default:
		panic("bad stream qid\n");
	}
	if(STREAMTYPE(c->qid) != Sdataqid)
		return streamctlwrite(c, a, n);

	/*
	 *  No writes allowed on hungup channels


@@ 1066,7 1068,7 @@ streamwrite(Chan *c, void *a, long n, int docopy)
	if(q->other->flag & QHUNGUP)
		error(0, Ehungup);

	if((GLOBAL(a) && !docopy) || n==0){
	if(!docopy && GLOBAL(a)){
		/*
		 *  `a' is global to the whole system, just create a
		 *  pointer to it and pass it on.


@@ 1103,9 1105,6 @@ streamwrite(Chan *c, void *a, long n, int docopy)
			}
		}
	}
out:
/*	qunlock(&s->wrlock);
	poperror(); /**/
	return n;
}


M port/sturp.c => port/sturp.c +2 -2
@@ 653,7 653,7 @@ output(Urp *up)
		 */
		up->rexmit = 0;
		up->next = up->unacked;
	} else if(up->unacked!=up->next && NOW>up->timer){
	} else if(up->unechoed!=up->next && NOW>up->timer){
		/*
		 *  if a retransmit time has elapsed since a transmit,
		 *  send an ENQ


@@ 944,7 944,7 @@ todo(void *arg)

	return (up->state&INITING)
	? NOW>up->timer					/* time to INIT1 */
	: ((up->unacked!=up->next && NOW>up->timer)	/* time to ENQ */
	: ((up->unechoed!=up->next && NOW>up->timer)	/* time to ENQ */
	  || WINDOW(up)>0 && up->next!=up->nxb
	  || (!QFULL(up->rq->next) && up->iseq!=(up->lastecho&7))); /* time to ECHO */
}

M power/devhs.c => power/devhs.c +1 -1
@@ 554,6 554,6 @@ hsvmeintr(int vec)
		hp->parity++;
		hsvmerestart(hp);
		print("hsvme %d: reset, csr = 0x%ux\n",
			HSVME, csr);
			vec - Vmevec, csr);
	}
}