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

1990/1009/port/stream.c (diff list | history)

1990/0930/sys/src/9/port/stream.c:235,2401990/1009/sys/src/9/port/stream.c:235,241 (short | long | prev | next)
1990/0227    
	q->info = qi; 
	q->put = qi->iput; 
1990/0403    
	q->len = q->nb = 0; 
1990/1009    
	q->ptr = 0; 
1990/0227    
	wq = q->other = q + 1; 
 
1990/0702    
	wq->flag = QINUSE; 
1990/0930/sys/src/9/port/stream.c:242,2471990/1009/sys/src/9/port/stream.c:243,249
1990/0227    
	wq->info = qi; 
	wq->put = qi->oput; 
	wq->other = q; 
1990/1009    
	wq->ptr = 0; 
1990/0403    
	wq->len = wq->nb = 0; 
1990/0227    
 
	unlock(q); 
1990/0930/sys/src/9/port/stream.c:625,6341990/1009/sys/src/9/port/stream.c:627,636
1990/0227    
} 
 
/* 
 *  create a new stream 
1990/1009    
 *  create a new stream, if noopen is non-zero, don't increment the open count 
1990/0227    
 */ 
Stream * 
streamnew(Chan *c, Qinfo *qi) 
1990/1009    
streamnew(ushort type, ushort dev, ushort id, Qinfo *qi, int noopen) 
1990/0227    
{ 
	Stream *s; 
	Queue *q; 
1990/0930/sys/src/9/port/stream.c:651,6761990/1009/sys/src/9/port/stream.c:653,677
1990/0227    
	} 
	if(waserror()){ 
		unlock(s); 
		streamclose(c); 
1990/1009    
		streamclose1(s); 
1990/0227    
		nexterror(); 
	} 
 
	/* 
	 *  marry a stream and a channel 
1990/1009    
	 *  identify the stream 
1990/0227    
	 */ 
	if(c){ 
		c->stream = s; 
		s->type = c->type; 
		s->dev = c->dev; 
		s->id = STREAMID(c->qid); 
	} else 
		s->type = -1; 
1990/1009    
	s->type = type; 
	s->dev = dev; 
	s->id = id; 
1990/0227    
 
	/* 
 	 *  hang a device and process q off the stream 
	 */ 
	s->inuse = 1; 
1990/0629    
	s->opens = 1; 
1990/1009    
	if(noopen) 
		s->opens = 0; 
	else 
		s->opens = 1; 
1990/0331    
	s->hread = 0; 
1990/0227    
	q = allocq(&procinfo); 
	s->procq = WR(q); 
1990/0930/sys/src/9/port/stream.c:699,7051990/1009/sys/src/9/port/stream.c:700,706
1990/0227    
	Queue *q; 
 
	/* 
	 *  if the stream already exists, just up the reference count. 
1990/1009    
	 *  if the stream already exists, just increment the reference counts. 
1990/0227    
	 */ 
	for(s = slist; s < &slist[conf.nstream]; s++) { 
		if(s->inuse && s->type == c->type && s->dev == c->dev 
1990/0930/sys/src/9/port/stream.c:721,7271990/1009/sys/src/9/port/stream.c:722,728
1990/0227    
	/* 
	 *  create a new stream 
	 */ 
	streamnew(c, qi); 
1990/1009    
	c->stream = streamnew(c->type, c->dev, STREAMID(c->qid), qi, 0); 
1990/0227    
} 
 
/* 
1990/0930/sys/src/9/port/stream.c:773,7911990/1009/sys/src/9/port/stream.c:774,785
1990/0227    
 *  stream release its blocks and call its close routine. 
 */ 
void 
streamclose(Chan *c) 
1990/1009    
streamclose1(Stream *s) 
1990/0227    
{ 
	Queue *q, *nq; 
	Block *bp; 
1990/03013    
	Stream *s = c->stream; 
1990/0227    
 
	/* 
	 *  if not open, ignore it 
	 */ 
1990/03292    
	if(!c->stream) 
1990/0227    
		return; 
                 
	/* 
1990/0629    
	 *  decrement the reference count 
1990/0227    
	 */ 
1990/03013    
	lock(s); 
1990/0930/sys/src/9/port/stream.c:817,8221990/1009/sys/src/9/port/stream.c:811,826
1990/0629    
	streamexit(s, 1); 
1990/03013    
	unlock(s); 
1990/0227    
} 
1990/1009    
void 
streamclose(Chan *c) 
{ 
	/* 
	 *  if no stream, ignore it 
	 */ 
	if(!c->stream) 
		return; 
	streamclose1(c->stream); 
} 
1990/0227    
 
/* 
 *  put a block to be read into the queue.  wakeup any waiting reader 
1990/0930/sys/src/9/port/stream.c:1174,11801990/1009/sys/src/9/port/stream.c:1178,1184
1990/0911    
 
	lock(q); 
	for(bp = q->first; bp; bp = bp->next){ 
		print("%c%d%c", c, bp->wptr-bp->rptr, (bp->flags&S_DELIM)); 
1990/1009    
		print("%c%d%c", c, bp->wptr-bp->rptr, (bp->flags&S_DELIM)?'D':' '); 
1990/0911    
		for(cp = bp->rptr; cp<bp->wptr && cp<bp->rptr+10; cp++) 
			print(" %uo", *cp); 
		print("\n"); 


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