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

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