home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.programmer:4449 comp.unix.wizards:3692
- Newsgroups: comp.unix.programmer,comp.unix.wizards
- Path: sparky!uunet!wupost!sdd.hp.com!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!cleveland.Freenet.Edu!am815
- From: am815@cleveland.Freenet.Edu (Joel Peter Anderson)
- Subject: STREAMS M_ERROR Message problem
- Message-ID: <1992Aug26.130739.19300@usenet.ins.cwru.edu>
- Sender: news@usenet.ins.cwru.edu
- Nntp-Posting-Host: slc5.ins.cwru.edu
- Reply-To: am815@cleveland.Freenet.Edu (Joel Peter Anderson)
- Organization: Case Western Reserve University, Cleveland, OH (USA)
- Date: Wed, 26 Aug 92 13:07:39 GMT
- Lines: 67
-
-
- I am running UHC's System V.4 Unix on a 486.
-
- I have a serial communications card which has loaded on it a
- protocol stack. A user application interacts with the protocol
- stack through a device driver whose head is a STREAM. To get and
- put data to the driver, a user application would use read() and
- write().
-
- Currently, if the protocol stack encounters an error on a user
- application write, it sends back to the driver a negative status
- code. The driver then converts this into a M_ERROR message which
- is put on the read queue using putq. To make turn the message into
- an M_ERROR message the following is done:
-
- make_error_msg(mblk_t *mp, int status_code) {
-
- mp->b_datap->db_type = M_ERROR;
- mp->b_rptr = mp->b_datap->db_base;
- *mp->b_rptr = status_code;
- mp->b_wptr = mp->b_rptr + sizeof(char);
- ....
- }
-
- The result is the next read or write returns with a -1 and errno is
- set to 256 - status_code. The PROBLEM is that the only way to
- clear the error condition is to close the device. Typically, the
- error does not warrent a close.
-
- The man pages on STREAMS error message types indicate that there
- are two forms of the M_ERROR message - one byte and two byte. The
- one byte form is suppose to lock out all system calls to the device
- except close and poll. However, the two byte form is set up so
- that "the first byte [of the status code] is the read error and the
- second byte is the write error. This allows for modules to set a
- different error on the read-side and write-side. This allows a
- module to set an error on just one side of the STREAM." When I
- change the code to construct a two-byte M_ERROR msg...
-
- make_error_msg(mblk_t *mp,char status_code) {
-
- mp->b_datap->db_type = M_ERROR;
- mp->b_rptr = mp->b_datap->db_base;
- *mp->b_rptr = status_code;
- *(mp->b_rptr + 1) = NOERROR;
- mp->b_wptr = mp->b_rptr + ( 2 * sizeof(char));
- }
-
- the result is the same as with the one byte M_ERROR message. Both
- read and writes return a -1 with errno = status_code. What am I
- doing wrong?
-
- -------------------------------------------------------------------------
- "We know only the strong will survive, But the meek will inherit.
- So if you've got a coat of arms, oh friend, I suggest we wear it."
- John Mellencamp.
- -------------------------------------------------------------------------
- joela@Apertus.COM s/w engneer |Freenet: am815@cleveland.freenet.edu
- Joel Peter Anderson |PNET: jpa@pnet51.orbit.mn.org
- Apertus Technologies |GEnie:J.ANDERSON71
- -------------------------------------------------------------------------
- --
- --------------------------------------------------------------------
- <Joel Peter Anderson> |
- Freenet: am815@cleveland.freenet.edu| Signature under
- GEnie:J.ANDERSON71 | construction.
-