home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / internal / 1748 < prev    next >
Encoding:
Text File  |  1992-08-26  |  3.3 KB  |  77 lines

  1. Newsgroups: comp.unix.internals
  2. Path: sparky!uunet!sun-barr!ames!agate!usenet.ins.cwru.edu!cleveland.Freenet.Edu!am815
  3. From: am815@cleveland.Freenet.Edu (Joel Peter Anderson)
  4. Subject: STREAMS M_ERROR Message problem
  5. Message-ID: <1992Aug26.130306.18891@usenet.ins.cwru.edu>
  6. Sender: news@usenet.ins.cwru.edu
  7. Nntp-Posting-Host: slc5.ins.cwru.edu
  8. Reply-To: am815@cleveland.Freenet.Edu (Joel Peter Anderson)
  9. Organization: Case Western Reserve University, Cleveland, OH (USA)
  10. Date: Wed, 26 Aug 92 13:03:06 GMT
  11. Lines:       65
  12.  
  13. I am running UHC's System V.4 Unix on a 486.
  14.  
  15. I have a serial communications card which has loaded on it a
  16. protocol stack.  A user application interacts with the protocol
  17. stack through a device driver whose head is a STREAM.  To get and
  18. put data to the driver, a user application would use read() and
  19. write().
  20.  
  21. Currently, if the protocol stack encounters an error on a user
  22. application write, it sends back to the driver a negative status
  23. code.  The driver then converts this into a M_ERROR message which
  24. is put on the read queue using putq.  To make turn the message into
  25. an M_ERROR message the following is done:
  26.  
  27. make_error_msg(mblk_t *mp, int status_code) {
  28.     
  29.     mp->b_datap->db_type = M_ERROR;
  30.     mp->b_rptr = mp->b_datap->db_base;
  31.     *mp->b_rptr = status_code;
  32.     mp->b_wptr = mp->b_rptr + sizeof(char);
  33.     ....
  34.  
  35. The result is the next read or write returns with a -1 and errno is
  36. set to 256 - status_code.  The PROBLEM is that the only way to
  37. clear the error condition is to close the device.  Typically, the
  38. error does not warrent a close.
  39.  
  40. The man pages on STREAMS error message types indicate that there
  41. are two forms of the M_ERROR message - one byte and two byte.  The
  42. one byte form is suppose to lock out all system calls to the device
  43. except close and poll.  However, the two byte form is set up so
  44. that "the first byte [of the status code] is the read error and the
  45. second byte is the write error.  This allows for modules to set a
  46. different error on the read-side and write-side.  This allows a
  47. module to set an error on just one side of the STREAM."  When I
  48. change the code to construct a two-byte M_ERROR msg...
  49.  
  50. make_error_msg(mblk_t *mp,char status_code) {
  51.     
  52.     mp->b_datap->db_type = M_ERROR;
  53.     mp->b_rptr = mp->b_datap->db_base;
  54.     *mp->b_rptr = status_code;
  55.     *(mp->b_rptr + 1) = NOERROR;
  56.     mp->b_wptr = mp->b_rptr + ( 2 * sizeof(char));
  57. }
  58.  
  59. the result is the same as with the one byte M_ERROR message.  Both
  60. read and writes return a -1 with errno = status_code.  What am I
  61. doing wrong?
  62. -------------------------------------------------------------------------
  63. "We know only the strong will survive, But the meek will inherit.
  64.  So if you've got a coat of arms, oh friend, I suggest we wear it."
  65.                                         John Mellencamp.
  66. -------------------------------------------------------------------------
  67.   joela@Apertus.COM  s/w engneer |Freenet: am815@cleveland.freenet.edu
  68.     Joel Peter Anderson          |PNET: jpa@pnet51.orbit.mn.org
  69.     Apertus Technologies         |GEnie:J.ANDERSON71
  70. -------------------------------------------------------------------------
  71. -- 
  72. -------------------------------------------------------------------- 
  73. <Joel Peter Anderson>               |     
  74. Freenet: am815@cleveland.freenet.edu|    Signature under 
  75.  GEnie:J.ANDERSON71                 |      construction.
  76.