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

1990/0621/gnot/stream.c (diff list | history)

1990/0620/sys/src/9/gnot/stream.c:531,5381990/0621/sys/src/9/gnot/stream.c:531,542 (short | long | prev | next)
1990/03091    
void 
nullput(Queue *q, Block *bp) 
{ 
	freeb(bp); 
	error(0, Ehungup); 
1990/0621    
	if(bp->type == M_HANGUP) 
		freeb(bp); 
	else { 
		freeb(bp); 
		error(0, Ehungup); 
	} 
1990/03091    
} 
 
/* 
1990/0620/sys/src/9/gnot/stream.c:757,7771990/0621/sys/src/9/gnot/stream.c:761,777
1990/0620    
 
	if(!locked) 
		lock(s); 
	s->inuse--; 
	if(s->inuse != 0){ 
		if(!locked) 
			unlock(s); 
		return; 
1990/0621    
	if(s->inuse == 1){ 
		/* 
		 *  ascend the stream freeing the queues 
		 */ 
		for(q = s->devq; q; q = nq){ 
			nq = q->next; 
			freeq(q); 
		} 
		s->id = s->dev = s->type = 0; 
1990/0620    
	} 
                 
	/* 
	 *  ascend the stream freeing the queues 
	 */ 
	for(q = s->devq; q; q = nq){ 
		nq = q->next; 
		freeq(q); 
	} 
	s->id = s->dev = s->type = 0; 
1990/0621    
	s->inuse--; 
1990/0620    
	if(!locked) 
		unlock(s); 
} 
1990/0620/sys/src/9/gnot/stream.c:797,8251990/0621/sys/src/9/gnot/stream.c:797,823
1990/0620    
	 *  decrement the reference count 
1990/03091    
	 */ 
	lock(s); 
1990/0620    
	if(s->opens != 1){ 
		s->opens--; 
1990/03091    
		unlock(c->stream); 
		return; 
1990/0621    
	if(s->opens == 1){ 
		/* 
		 *  descend the stream closing the queues 
		 */ 
		for(q = s->procq; q; q = q->next){ 
			if(q->info->close) 
				(*q->info->close)(q->other); 
			/* 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); 
		} 
1990/03091    
	} 
                 
	/* 
	 *  descend the stream closing the queues 
	 */ 
	for(q = s->procq; q; q = q->next){ 
		if(q->info->close) 
			(*q->info->close)(q->other); 
		if(q == s->devq->other) 
			break; 
	} 
1990/0620    
                 
1990/03091    
	/* 
1990/0620    
	 *  ascend the stream flushing the queues 
1990/03091    
	 */ 
	for(q = s->devq; q; q = nq){ 
		nq = q->next; 
1990/0620    
		flushq(q); 
1990/03091    
	} 
1990/0621    
	s->opens--; 
1990/0620    
 
	/* 
	 *  leave it and free it 


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