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

1991/1227/port/devpipe.c (diff list | history)

1991/1115/sys/src/9/port/devpipe.c:13,191991/1227/sys/src/9/port/devpipe.c:13,19 (short | long | prev | next)
1990/1009    
struct Pipe 
{ 
	Ref; 
	int	debug; 
1991/1227    
	QLock; 
1990/1009    
	Pipe	*next; 
}; 
 
1991/1115/sys/src/9/port/devpipe.c:88,931991/1227/sys/src/9/port/devpipe.c:88,94
1990/1009    
	unlock(&pipealloc); 
 
1990/11211    
	c->qid = (Qid){CHDIR|STREAMQID(2*(p - pipealloc.pipe), 0), 0}; 
1991/1227    
	c->dev = 0; 
1990/0227    
	return c; 
} 
 
1991/1115/sys/src/9/port/devpipe.c:150,1701991/1227/sys/src/9/port/devpipe.c:151,168
1990/1009    
	} 
 
1990/11211    
	p = &pipealloc.pipe[STREAMID(c->qid.path)/2]; 
1990/1009    
	remote = 0; 
	if(waserror()){ 
		unlock(p); 
		if(remote) 
			streamclose1(remote); 
1991/1227    
		qunlock(p); 
1990/1009    
		nexterror(); 
	} 
	lock(p); 
1991/1227    
	qlock(p); 
1990/1009    
	streamopen(c, &pipeinfo); 
	local = c->stream; 
	if(local->devq->ptr == 0){ 
		/* 
		 *  First stream opened, create the other end also 
1991/1227    
		 *  first open, create the other end also 
1990/1009    
		 */ 
1990/11211    
		remote = streamnew(c->type, c->dev, STREAMID(c->qid.path)^1, &pipeinfo, 1); 
1991/1227    
		remote = streamnew(c->type, c->dev, STREAMID(c->qid.path)^1, &pipeinfo,1); 
1990/1009    
 
		/* 
		 *  connect the device ends of both streams 
1991/1115/sys/src/9/port/devpipe.c:173,1871991/1227/sys/src/9/port/devpipe.c:171,183
1990/1009    
		remote->devq->ptr = local; 
		local->devq->other->next = remote->devq; 
		remote->devq->other->next = local->devq; 
                 
1991/1227    
	} else if(local->opens == 1){ 
1990/1009    
		/* 
		 *  increment the inuse count to reflect the 
		 *  pointer from the other stream. 
1991/1227    
		 *  keep other side around till last close of this side 
1990/1009    
		 */ 
		if(streamenter(local)<0) 
1990/1118    
			panic("pipeopen"); 
1991/1227    
		streamenter(local->devq->ptr); 
1990/1009    
	} 
	unlock(p); 
1991/1227    
	qunlock(p); 
1990/1009    
	poperror(); 
 
	c->mode = omode&~OTRUNC; 
1991/1115/sys/src/9/port/devpipe.c:220,2331991/1227/sys/src/9/port/devpipe.c:216,231
1990/11211    
	p = &pipealloc.pipe[STREAMID(c->qid.path)/2]; 
1990/0629    
 
1990/1009    
	/* 
1990/1011    
	 *  take care of associated streams 
1991/1227    
	 *  take care of local and remote streams 
1990/1009    
	 */ 
1990/11211    
	if(c->stream){ 
1991/1227    
		qlock(p); 
1990/11211    
		remote = c->stream->devq->ptr; 
1991/0314    
		if(streamclose(c) <= 0){ 
1991/1227    
		if(streamclose(c) == 0){ 
1991/0314    
			if(remote) 
				streamexit(remote, 0); 
		} 
1991/1227    
		qunlock(p); 
1990/11211    
	} 
1990/11161    
 
	/* 
1991/1115/sys/src/9/port/devpipe.c:284,2911991/1227/sys/src/9/port/devpipe.c:282,288
1990/0227    
} 
 
/* 
 *  send the block to the other side without letting the connection 
 *  disappear in mid put. 
1991/1227    
 *  send the block to the other side 
1990/0227    
 */ 
static void 
pipeoput(Queue *q, Block *bp) 
1991/1115/sys/src/9/port/devpipe.c:300,3061991/1227/sys/src/9/port/devpipe.c:297,302
1990/0227    
pipestclose(Queue *q) 
{ 
	Block *bp; 
1990/1118    
	Stream *remote; 
1990/0227    
 
	/* 
	 *  point to the bit-bucket and let any in-progress 


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