Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / qreply.9f
blobc7c882d3612425334a5fb6d53e609e30bf39c0bb
1 '\" te
2 .\"  Copyright 1989 AT&T
3 .\"  Copyright (c) 2006, Sun Microsystems, Inc.,  All Rights Reserved
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH QREPLY 9F "Jan 16, 2006"
8 .SH NAME
9 qreply \- send a message on a stream in the reverse direction
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/stream.h>
17 \fBvoid\fR \fBqreply\fR(\fBqueue_t *\fR\fIq\fR, \fBmblk_t *\fR\fImp\fR);
18 .fi
20 .SH INTERFACE LEVEL
21 .sp
22 .LP
23 Architecture independent level 1 (DDI/DKI).
24 .SH PARAMETERS
25 .sp
26 .ne 2
27 .na
28 \fB\fIq\fR\fR
29 .ad
30 .RS 6n
31 Pointer to the queue.
32 .RE
34 .sp
35 .ne 2
36 .na
37 \fB\fImp\fR\fR
38 .ad
39 .RS 6n
40 Pointer to the message to be sent in the opposite direction.
41 .RE
43 .SH DESCRIPTION
44 .sp
45 .LP
46 The \fBqreply()\fR function sends messages in the reverse direction of normal
47 flow. That is, \fBqreply(\fR\fIq\fR\fB,\fR \fImp\fR\fB)\fR is equivalent to
48 \fBputnext(OTHERQ(\fR\fIq\fR\fB),\fR \fImp\fR\fB)\fR.
49 .SH CONTEXT
50 .sp
51 .LP
52 The \fBqreply()\fR function can be called from user, interrupt, or kernel
53 context.
54 .SH EXAMPLES
55 .LP
56 \fBExample 1 \fRCanonical Flushing Code for STREAMS Drivers.
57 .sp
58 .LP
59 This example depicts the canonical flushing code for STREAMS drivers. Assume
60 that the driver has service procedures so that there may be messages on its
61 queues. See \fBsrv\fR(9E). Its write-side put procedure handles \fBM_FLUSH\fR
62 messages by first checking the \fBFLUSHW\fR bit  in the first byte of the
63 message, then the write queue is flushed (line 8) and the \fBFLUSHW\fR bit is
64 turned off (line 9). See \fBput\fR(9E). If the \fBFLUSHR\fR bit is on, then the
65 read queue is flushed (line 12) and the message is sent back up the read side
66 of the stream with the \fBqreply()\fR function (line 13). If the \fBFLUSHR\fR
67 bit is off, then the message is freed (line 15). See the example for
68 \fBflushq\fR(9F) for the canonical flushing code for modules.
70 .sp
71 .in +2
72 .nf
73 1  xxxwput(q, mp)
74  2    queue_t *q;
75  3    mblk_t *mp;
76  4  {
77  5          switch(mp->b_datap->db_type) {
78  6          case M_FLUSH:
79  7           if (*mp->b_rptr & FLUSHW) {
80  8                  flushq(q, FLUSHALL);
81  9                  *mp->b_rptr &= ~FLUSHW;
82 10                }
83 11           if (*mp->b_rptr & FLUSHR) {
84 12                  flushq(RD(q), FLUSHALL);
85 13                       qreply(q, mp);
86 14           } else {
87 15                       freemsg(mp);
88 16                }
89 17           break;
90               ...
91 18     }
92 19  }
93 .fi
94 .in -2
96 .SH SEE ALSO
97 .sp
98 .LP
99 \fBput\fR(9E), \fBsrv\fR(9E), \fBflushq\fR(9F), \fBOTHERQ\fR(9F),
100 \fBputnext\fR(9F)
103 \fIWriting Device Drivers\fR
106 \fISTREAMS Programming Guide\fR