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

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

1990/11151/sys/src/9/port/stream.c:652,6611990/11161/sys/src/9/port/stream.c:652,661 (short | long | prev | next)
1990/0227    
	 */ 
	for(s = slist; s < &slist[conf.nstream]; s++) { 
		if(s->inuse == 0){ 
			if(canlock(s)){ 
1990/11161    
			if(canqlock(s)){ 
1990/0227    
				if(s->inuse == 0) 
					break; 
				unlock(s); 
1990/11161    
				qunlock(s); 
1990/0227    
			} 
		} 
	} 
1990/11151/sys/src/9/port/stream.c:664,6701990/11161/sys/src/9/port/stream.c:664,670
1990/0227    
		error(0, Enostream); 
	} 
	if(waserror()){ 
		unlock(s); 
1990/11161    
		qunlock(s); 
1990/1009    
		streamclose1(s); 
1990/0227    
		nexterror(); 
	} 
1990/11151/sys/src/9/port/stream.c:697,7031990/11161/sys/src/9/port/stream.c:697,703
1990/0227    
	if(qi->open) 
		(*qi->open)(RD(s->devq), s); 
 
	unlock(s); 
1990/11161    
	qunlock(s); 
1990/0227    
	poperror(); 
	return s; 
} 
1990/11151/sys/src/9/port/stream.c:717,7231990/11161/sys/src/9/port/stream.c:717,723
1990/0227    
	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); 
1990/11161    
			qlock(s); 
1990/0227    
			if(s->inuse && s->type == c->type 
			&& s->dev == c->dev 
		 	&& s->id == STREAMID(c->qid)){ 
1990/11151/sys/src/9/port/stream.c:724,7331990/11161/sys/src/9/port/stream.c:724,733
1990/0227    
				s->inuse++; 
1990/0629    
				s->opens++; 
1990/0227    
				c->stream = s; 
				unlock(s); 
1990/11161    
				qunlock(s); 
1990/0227    
				return; 
			} 
			unlock(s); 
1990/11161    
			qunlock(s); 
1990/0227    
		} 
	} 
 
1990/11151/sys/src/9/port/stream.c:744,7561990/11161/sys/src/9/port/stream.c:744,756
1990/0629    
int 
streamenter(Stream *s) 
{ 
	lock(s); 
1990/11161    
	qlock(s); 
1990/0629    
	if(s->opens == 0){ 
		unlock(s); 
1990/11161    
		qunlock(s); 
1990/0629    
		return -1; 
	} 
	s->inuse++; 
	unlock(s); 
1990/11161    
	qunlock(s); 
1990/0629    
	return 0; 
} 
 
1990/11151/sys/src/9/port/stream.c:767,7731990/11161/sys/src/9/port/stream.c:767,773
1990/1104    
	char *name; 
1990/0629    
 
	if(!locked) 
		lock(s); 
1990/11161    
		qlock(s); 
1990/0629    
	if(s->inuse == 1){ 
1990/1104    
		if(s->opens != 0) 
1990/11151    
			panic("streamexit %d %s\n", s->opens, s->devq->info->name); 
1990/11151/sys/src/9/port/stream.c:784,7901990/11161/sys/src/9/port/stream.c:784,790
1990/0629    
	s->inuse--; 
1990/1101    
	rv = s->inuse; 
1990/0629    
	if(!locked) 
		unlock(s); 
1990/11161    
		qunlock(s); 
1990/1101    
	return rv; 
1990/0629    
} 
 
1990/11151/sys/src/9/port/stream.c:801,8241990/11161/sys/src/9/port/stream.c:801,824
1990/0227    
	/* 
1990/0629    
	 *  decrement the reference count 
1990/0227    
	 */ 
1990/03013    
	lock(s); 
1990/11161    
	qlock(s); 
1990/0629    
	if(s->opens == 1){ 
1990/1011    
		if(!waserror()){ 
			/* 
			 *  descend the stream closing the queues 
			 */ 
			for(q = s->procq; q; q = q->next){ 
1990/11161    
		/* 
		 *  descend the stream closing the queues 
		 */ 
		for(q = s->procq; q; q = q->next){ 
			if(!waserror()){ 
1990/1011    
				if(q->info->close) 
					(*q->info->close)(q->other); 
1990/1101    
				WR(q)->put = nullput; 
                 
1990/1011    
				/* 
				 *  this may be 2 streams joined device end to device end 
				 */ 
				if(q == s->devq->other) 
					break; 
1990/11161    
				poperror(); 
1990/1011    
			} 
			poperror(); 
1990/11161    
			WR(q)->put = nullput; 
 
			/* 
			 *  this may be 2 streams joined device end to device end 
			 */ 
			if(q == s->devq->other) 
				break; 
1990/0629    
		} 
	 
		/* 
1990/11151/sys/src/9/port/stream.c:835,8411990/11161/sys/src/9/port/stream.c:835,841
1990/0629    
	 *  leave it and free it 
1990/0227    
	 */ 
1990/0629    
	streamexit(s, 1); 
1990/03013    
	unlock(s); 
1990/11161    
	qunlock(s); 
1990/0227    
} 
1990/1009    
void 
streamclose(Chan *c) 


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