STREAMS-UX Programmer's Guide (February 2007)
Multiplexing
STREAMS Multiplexor
Chapter 5
137
Lower Read Service Procedure
The lower read service procedure is responsible for taking the messages of the read queue and routing them
to the appropriate upper stream if there are no errors. It is assumed here that the messages arriving at the
multiplexor's lower read queue contain the information regarding the destination stream, like a minor device
number associated with the upper stream. The information is extracted and the message is appropriately
routed.
The lower stream feeds the upper stream until it encounters a flow controlled stream.
int
mux_lrsrv(q)
queue_t * q;
{
...
if (muxerr) {
/* flush all the data on this queue */
...
return;
}
/* Route the data to the appropriate upper stream */
while(mp = getq(q)) {
/* Extract the minor device number from the message */
...
minor_dev = extract_minor(mp);
/* The minor device number should be in the allowed range */
if (minor_dev < 0 || minor_dev > MUXCNT) {
freemsg(mp);
} else {
if ( mux_list[minor_dev].top_rq)
if (canputnext(mux_list[minor_dev].top_rq))
putnext(mux_list[minor_dev].top_rq, mp);
else {
putbq(q,mp);
return;
}
}
} /* end while */
}