home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / bsd / 10632 < prev    next >
Encoding:
Text File  |  1992-12-25  |  3.4 KB  |  127 lines

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!mcsun!fuug!kiae!demos!newsserv
  2. From: ache@astral.msk.su (Andrew A. Chernov, Black Mage)
  3. Newsgroups: comp.unix.bsd
  4. Subject: [386bsd] patch for cgd's multiport com driver, select() bug fix
  5. Message-ID: <lFjp1EhiA0@astral.msk.su>
  6. Date: 23 Dec 92 08:01:49 GMT
  7. Sender: news-service@newcom.kiae.su
  8. Reply-To: ache@astral.msk.su
  9. Organization: Ha-oh-lahm Yetzirah
  10. Lines: 115
  11.  
  12. I just found this bug, maybe, it present in standard com driver too...
  13. I don't use it and can't check.
  14.  
  15. BUG DESCRIPTION:
  16. select() call don't work at all.
  17.  
  18. WHY:
  19. ttselect() kernel routine used for coms too, its code say:
  20.     register struct tty *tp = &cdevsw[major(dev)].d_ttys[minor(dev)];
  21. but for cgd's multiport com driver it must be:
  22.     register struct tty *tp = &com_tty[UNIT(dev)];
  23.  
  24. FIX:
  25. Simple, duplicate ttselect() code into comselect() code
  26. with replacing above. Modify conf.c ttselect()-->comselect()
  27.  
  28.  
  29. *** /sys/i386/isa/com.c.cgd.was       Thu Dec 10 01:07:29 1992
  30. --- /sys/i386/isa/com.c       Wed Dec 23 10:11:01 1992
  31. ***************
  32. *** 932,934 ****
  33. --- 932,973 ----
  34.       return 0;
  35.   }
  36.   #endif
  37. + int
  38. + comselect(dev, rw, p)
  39. +     dev_t dev;
  40. +     int rw;
  41. +     struct proc *p;
  42. + {
  43. +     register struct tty *tp = &com_tty[UNIT(dev)];
  44. +     int nread;
  45. +     int s = spltty();
  46. +     switch (rw) {
  47. +     case FREAD:
  48. +         nread = ttnread(tp);
  49. +         if (nread > 0 || 
  50. +            ((tp->t_cflag&CLOCAL) == 0 && (tp->t_state&TS_CARR_ON) == 0))
  51. +             goto win;
  52. +         if (tp->t_rsel && tp->t_rsel->p_wchan == (caddr_t)&selwait)
  53. +             tp->t_state |= TS_RCOLL;
  54. +         else
  55. +             tp->t_rsel = p;
  56. +         break;
  57. +     case FWRITE:
  58. +         if (RB_LEN(&tp->t_out) <= tp->t_lowat)
  59. +             goto win;
  60. +         if (tp->t_wsel && tp->t_wsel->p_wchan == (caddr_t)&selwait)
  61. +             tp->t_state |= TS_WCOLL;
  62. +         else
  63. +             tp->t_wsel = p;
  64. +         break;
  65. +     }
  66. +     splx(s);
  67. +     return (0);
  68. + win:
  69. +     splx(s);
  70. +     return (1);
  71. + }
  72. *** /sys/i386/i386/conf.c.cgd.was      Mon Nov 23 08:00:07 1992
  73. --- /sys/i386/i386/conf.c      Wed Dec 23 10:13:12 1992
  74. ***************
  75. *** 152,158 ****
  76.   
  77.   #include "com.h"
  78.   #if NCOM > 0
  79. ! int    comopen(),comclose(),comread(),comwrite(),comioctl();
  80.   #define comreset    enxio
  81.   extern    struct tty com_tty[];
  82.   #else
  83. --- 152,158 ----
  84.   
  85.   #include "com.h"
  86.   #if NCOM > 0
  87. ! int     comopen(),comclose(),comread(),comwrite(),comioctl(),comselect();
  88.   #define comreset    enxio
  89.   extern    struct tty com_tty[];
  90.   #else
  91. ***************
  92. *** 162,167 ****
  93. --- 162,168 ----
  94.   #define comwrite    enxio
  95.   #define comioctl    enxio
  96.   #define comreset    enxio
  97. + #define comselect       enxio
  98.   #define    com_tty        NULL
  99.   #endif
  100.   
  101. ***************
  102. *** 220,226 ****
  103.         logselect,    enodev,        NULL },
  104.       { comopen,    comclose,    comread,    comwrite,    /*8*/
  105.         comioctl,    enodev,        comreset,    com_tty,
  106. !       ttselect,    enodev,        NULL },
  107.       { Fdopen,    fdclose,    rawread,    rawwrite,    /*9*/
  108.         fdioctl,    enodev,        nullop,        NULL,
  109.         seltrue,    enodev,        fdstrategy },
  110. --- 221,227 ----
  111.         logselect,    enodev,        NULL },
  112.       { comopen,    comclose,    comread,    comwrite,    /*8*/
  113.         comioctl,    enodev,        comreset,    com_tty,
  114. !       comselect,    enodev,         NULL },
  115.       { Fdopen,    fdclose,    rawread,    rawwrite,    /*9*/
  116.         fdioctl,    enodev,        nullop,        NULL,
  117.         seltrue,    enodev,        fdstrategy },
  118. -- 
  119. In-This-Life:  Andrew A. Chernov    |  "Hay mas dicha, mas contento
  120. Internet:      ache@astral.msk.su   |  "Que adorar una hermosura
  121. Organization:  The RELCOM Corp.,    |  "Brujuleada entre los lejos
  122.                Moscow, Russia       |  "De lo imposible?!"  (Calderon)
  123.