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

2000/0914/port/qio.c (diff list | history)

2000/0913/sys/src/9/port/qio.c:902,9192000/0914/sys/src/9/port/qio.c:902,917 (short | long | prev | next)
1994/0208    
		nexterror(); 
1994/0804    
	} 
1994/0208    
 
1995/0714    
	/* flow control */ 
1998/0328    
	for(;;){ 
		ilock(q); 
2000/0914    
	ilock(q); 
1998/0328    
 
		if(q->state & Qclosed){ 
			iunlock(q); 
			error(q->err); 
		} 
2000/0914    
	/* give up if the queue is closed */ 
	if(q->state & Qclosed){ 
		iunlock(q); 
		error(q->err); 
	} 
1998/0328    
 
		if(q->len < q->limit) 
			break; 
                 
2000/0914    
	/* if nonblocking, don't queue over the limit */ 
	if(q->len >= q->limit){ 
1995/0714    
		if(q->noblock){ 
1998/0328    
			iunlock(q); 
1995/0714    
			freeb(b); 
2000/0913/sys/src/9/port/qio.c:921,9322000/0914/sys/src/9/port/qio.c:919,927
1994/0208    
			poperror(); 
1995/0714    
			return n; 
1993/1227    
		} 
1998/0328    
                 
1995/0714    
		q->state |= Qflow; 
1998/0328    
		iunlock(q); 
1995/0714    
		sleep(&q->wr, qnotfull, q); 
1993/0526    
	} 
 
2000/0914    
	/* queue the block */ 
1995/0714    
	if(q->bfirst) 
		q->blast->next = b; 
	else 
2000/0913/sys/src/9/port/qio.c:938,9482000/0914/sys/src/9/port/qio.c:933,943
1998/0605    
	QDEBUG checkb(b, "qbwrite"); 
2000/0913    
	b = nil; 
1995/0714    
 
2000/0914    
	/* make sure other end gets awakened */ 
1995/0714    
	if(q->state & Qstarve){ 
		q->state &= ~Qstarve; 
		dowakeup = 1; 
	} 
                 
	iunlock(q); 
 
	if(dowakeup){ 
2000/0913/sys/src/9/port/qio.c:950,9552000/0914/sys/src/9/port/qio.c:945,973
1997/0327    
			q->kick(q->arg); 
1995/0714    
		wakeup(&q->rr); 
	} 
2000/0914    
 
	/* 
	 *  flow control, wait for queue to get below the limit 
	 *  before allowing the process to continue and queue 
	 *  more.  We do this here so that postnote can only 
	 *  interrupt us after the data has been quued.  This 
	 *  means that things like 9p flushes and ssl messages 
	 *  will not be disrupted by software interrupts. 
	 * 
	 *  Note - this is moderately dangerous since a process 
	 *  that keeps getting interrupted and rewriting will 
	 *  queue infinite crud. 
	 */ 
	for(;;){ 
		if(q->noblock || qnotfull(q)) 
			break; 
 
		ilock(q); 
		q->state |= Qflow; 
		iunlock(q); 
		sleep(&q->wr, qnotfull, q); 
	} 
	USED(b); 
1995/0714    
 
	qunlock(&q->wlock); 
	poperror(); 


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