home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / programm / 4449 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  3.5 KB

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