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

1990/1115/port/devpipe.c (diff list | history)

1990/1113/sys/src/9/port/devpipe.c:82,911990/1115/sys/src/9/port/devpipe.c:82,89 (short | long | prev | next)
1990/1009    
	} 
	p = pipealloc.free; 
	pipealloc.free = p->next; 
1990/1104    
	if(++(p->ref) != 1){ 
		print("pipattach pipe half %d ref %d\n", p - pipealloc.pipe, p->ref); 
1990/1115    
	if(incref(p) != 1) 
1990/1013    
		panic("pipeattach"); 
1990/1104    
	} 
1990/1009    
	unlock(&pipealloc); 
 
	c->qid = CHDIR|STREAMQID(2*(p - pipealloc.pipe), 0); 
1990/1113/sys/src/9/port/devpipe.c:210,2151990/1115/sys/src/9/port/devpipe.c:208,226
1990/0227    
} 
 
void 
1990/1115    
pipeexit(Pipe *p) 
{ 
	if(decref(p) < 0) 
		panic("pipeexit"); 
	if(p->ref == 0){ 
		lock(&pipealloc); 
		p->next = pipealloc.free; 
		pipealloc.free = p; 
		unlock(&pipealloc); 
	} 
} 
 
void 
1990/0227    
pipeclose(Chan *c) 
{ 
1990/1009    
	Stream *remote; 
1990/1113/sys/src/9/port/devpipe.c:217,2221990/1115/sys/src/9/port/devpipe.c:228,238
1990/1009    
	Pipe *p; 
1990/0629    
 
1990/1009    
	p = &pipealloc.pipe[STREAMID(c->qid)/2]; 
1990/1115    
	lock(p); 
	if(waserror()){ 
		unlock(p); 
		nexterror(); 
	} 
1990/0629    
 
1990/1009    
	/* 
1990/1011    
	 *  take care of associated streams 
1990/1113/sys/src/9/port/devpipe.c:226,2421990/1115/sys/src/9/port/devpipe.c:242,250
1990/1009    
		streamclose(c);		/* close this stream */ 
		streamexit(remote, 0);	/* release stream for other half of pipe */ 
1990/0629    
	} 
1990/1104    
                 
	lock(p); 
	if(--(p->ref) < 0) 
		panic("pipeexit"); 
	if(p->ref == 0){ 
		lock(&pipealloc); 
		p->next = pipealloc.free; 
		pipealloc.free = p; 
		unlock(&pipealloc); 
	} 
	unlock(p); 
1990/1115    
	poperror(); 
	pipeexit(p); 
1990/0227    
} 
 
long 


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