Print this page
8527 tty buffer/queue sizes should be larger


 549 #define DEBUG4(a)
 550 #define DEBUG5(a)
 551 #define DEBUG6(a)
 552 #define DEBUG7(a)
 553 #endif          /* LDDEBUG */
 554 
 555 
 556 /*
 557  * Since most of the buffering occurs either at the stream head or in
 558  * the "message currently being assembled" buffer, we have a
 559  * relatively small input queue, so that blockages above us get
 560  * reflected fairly quickly to the module below us.  We also have a
 561  * small maximum packet size, since you can put a message of that
 562  * size on an empty queue no matter how much bigger than the high
 563  * water mark it is.
 564  */
 565 static struct module_info ldtermmiinfo = {
 566         0x0bad,
 567         "ldterm",
 568         0,
 569         256,
 570         HIWAT,
 571         LOWAT
 572 };
 573 
 574 
 575 static struct qinit ldtermrinit = {
 576         (int (*)())ldtermrput,
 577         (int (*)())ldtermrsrv,
 578         ldtermopen,
 579         ldtermclose,
 580         NULL,
 581         &ldtermmiinfo
 582 };
 583 
 584 
 585 static struct module_info ldtermmoinfo = {
 586         0x0bad,
 587         "ldterm",
 588         0,
 589         INFPSZ,
 590         1,


 776                 putnext(wq, qryp);
 777         }
 778 
 779         /* prepare to clear the water marks on close */
 780         if ((bp = open_mblk(q, sizeof (struct stroptions))) == NULL)
 781                 goto open_abort;
 782         tp->t_closeopts = bp;
 783 
 784         /*
 785          * Set the high-water and low-water marks on the stream head
 786          * to values appropriate for a terminal.  Also set the "vmin"
 787          * and "vtime" values to 1 and 0, turn on message-nondiscard
 788          * mode (as we're in ICANON mode), and turn on "old-style
 789          * NODELAY" mode.
 790          */
 791         if ((bp = open_mblk(q, sizeof (struct stroptions))) == NULL)
 792                 goto open_abort;
 793         strop = (struct stroptions *)bp->b_wptr;
 794         strop->so_flags = SO_READOPT|SO_HIWAT|SO_LOWAT|SO_NDELON|SO_ISTTY;
 795         strop->so_readopt = RMSGN;
 796         strop->so_hiwat = HIWAT;
 797         strop->so_lowat = LOWAT;
 798         bp->b_wptr += sizeof (struct stroptions);
 799         bp->b_datap->db_type = M_SETOPTS;
 800         putnext(q, bp);
 801 
 802         return (0);             /* this can become a controlling TTY */
 803 
 804 open_abort:
 805         qprocsoff(q);
 806         q->q_ptr = NULL;
 807         WR(q)->q_ptr = NULL;
 808         freemsg(tp->t_closeopts);
 809         freemsg(tp->t_drainmsg);
 810         /* Dump the state structure */
 811         kmem_free(tp, sizeof (ldtermstd_state_t));
 812         return (EINTR);
 813 }
 814 
 815 struct close_timer {
 816         timeout_id_t id;


1878                                 bpt = NULL;
1879                                 *dofreep = 0;
1880                         } else {
1881                                 bpt = newmsg(tp);
1882                                 *dofreep = 1;
1883                         }
1884                         goto out;
1885                 }
1886         }
1887 
1888 escaped:
1889         /*
1890          * First, make sure we can fit one WHOLE multi-byte char in the
1891          * buffer.  This is one place where we have overhead even if
1892          * not in multi-byte mode; the overhead is subtracting
1893          * tp->t_maxeuc from MAX_CANON before checking.
1894          *
1895          * Allows MAX_CANON bytes in the buffer before throwing awaying
1896          * the the overflow of characters.
1897          */
1898         if ((tp->t_msglen > ((MAX_CANON + 1) - (int)tp->t_maxeuc)) &&
1899             !((tp->t_state & TS_MEUC) && tp->t_eucleft)) {
1900 
1901                 /*
1902                  * Byte will cause line to overflow, or the next EUC
1903                  * won't fit: Ring the bell or discard all input, and
1904                  * don't save the byte away.
1905                  */
1906                 if (tp->t_modes.c_iflag & IMAXBEL) {
1907                         if (canputnext(wrq))
1908                                 ldterm_outchar(CTRL('g'), wrq, ebsize, tp);
1909                         goto out;
1910                 } else {
1911                         /*
1912                          * MAX_CANON processing. free everything in
1913                          * the current line and start with the
1914                          * current character as the first character.
1915                          */
1916                         DEBUG7(("ldterm_docanon: MAX_CANON processing\n"));
1917                         freemsg(tp->t_message);
1918                         tp->t_message = NULL;


4366                          */
4367                         tp->t_maxeuc = 0;    /* reset to say we're NOT */
4368 
4369                         tp->t_state &= ~TS_MEUC;
4370                         /*
4371                          * We'll set TS_MEUC if we're doing
4372                          * multi-column OR multi- byte OR both.  It
4373                          * makes things easier...  NOTE:  If we fail
4374                          * to get the buffer we need to hold display
4375                          * widths, then DON'T let the TS_MEUC bit get
4376                          * set!
4377                          */
4378                         for (i = 0; i < 4; i++) {
4379                                 if (tp->eucwioc.eucw[i] > tp->t_maxeuc)
4380                                         tp->t_maxeuc = tp->eucwioc.eucw[i];
4381                                 if (tp->eucwioc.scrw[i] > 1)
4382                                         tp->t_state |= TS_MEUC;
4383                         }
4384                         if ((tp->t_maxeuc > 1) || (tp->t_state & TS_MEUC)) {
4385                                 if (!tp->t_eucp_mp) {
4386                                         if (!(tp->t_eucp_mp = allocb(CANBSIZ,
4387                                             BPRI_HI))) {
4388                                                 tp->t_maxeuc = 1;
4389                                                 tp->t_state &= ~TS_MEUC;
4390                                                 cmn_err(CE_WARN,
4391                                                     "Can't allocate eucp_mp");
4392                                                 miocnak(q, mp, 0, ENOSR);
4393                                                 return;
4394                                         }
4395                                         /*
4396                                          * here, if there's junk in
4397                                          * the canonical buffer, then
4398                                          * move the eucp pointer past
4399                                          * it, so we don't run off
4400                                          * the beginning.  This is a
4401                                          * total botch, but will
4402                                          * hopefully keep stuff from
4403                                          * getting too messed up
4404                                          * until the user flushes
4405                                          * this line!
4406                                          */
4407                                         if (tp->t_msglen) {


4595                                 return;
4596                         }
4597 
4598                         locale_name_sz = i + 1;
4599                 }
4600 
4601                 /*
4602                  * As the final check, if there was invalid codeset_type
4603                  * given, or invalid byte_length was specified, it's an error.
4604                  */
4605                 if (maxbytelen <= 0 || maxscreenlen <= 0) {
4606                         miocnak(q, mp, 0, ERANGE);
4607                         return;
4608                 }
4609 
4610                 /* Do the switching. */
4611                 tp->t_maxeuc = maxbytelen;
4612                 tp->t_state &= ~TS_MEUC;
4613                 if (maxbytelen > 1 || maxscreenlen > 1) {
4614                         if (!tp->t_eucp_mp) {
4615                                 if (!(tp->t_eucp_mp = allocb(CANBSIZ,
4616                                     BPRI_HI))) {
4617                                         cmn_err(CE_WARN,
4618                                             "Can't allocate eucp_mp");
4619                                         miocnak(q, mp, 0, ENOSR);
4620                                         return;
4621                                 }
4622                                 /*
4623                                  * If there's junk in the canonical buffer,
4624                                  * then move the eucp pointer past it,
4625                                  * so we don't run off the beginning. This is
4626                                  * a total botch, but will hopefully keep
4627                                  * stuff from getting too messed up until
4628                                  * the user flushes this line!
4629                                  */
4630                                 if (tp->t_msglen) {
4631                                         tp->t_eucp = tp->t_eucp_mp->b_rptr;
4632                                         for (i = tp->t_msglen; i; i--)
4633                                                 *tp->t_eucp++ = 1;
4634                                 } else {
4635                                         tp->t_eucp = tp->t_eucp_mp->b_rptr;




 549 #define DEBUG4(a)
 550 #define DEBUG5(a)
 551 #define DEBUG6(a)
 552 #define DEBUG7(a)
 553 #endif          /* LDDEBUG */
 554 
 555 
 556 /*
 557  * Since most of the buffering occurs either at the stream head or in
 558  * the "message currently being assembled" buffer, we have a
 559  * relatively small input queue, so that blockages above us get
 560  * reflected fairly quickly to the module below us.  We also have a
 561  * small maximum packet size, since you can put a message of that
 562  * size on an empty queue no matter how much bigger than the high
 563  * water mark it is.
 564  */
 565 static struct module_info ldtermmiinfo = {
 566         0x0bad,
 567         "ldterm",
 568         0,
 569         _TTY_BUFSIZ,
 570         _TTY_BUFSIZ,
 571         LOWAT
 572 };
 573 
 574 
 575 static struct qinit ldtermrinit = {
 576         (int (*)())ldtermrput,
 577         (int (*)())ldtermrsrv,
 578         ldtermopen,
 579         ldtermclose,
 580         NULL,
 581         &ldtermmiinfo
 582 };
 583 
 584 
 585 static struct module_info ldtermmoinfo = {
 586         0x0bad,
 587         "ldterm",
 588         0,
 589         INFPSZ,
 590         1,


 776                 putnext(wq, qryp);
 777         }
 778 
 779         /* prepare to clear the water marks on close */
 780         if ((bp = open_mblk(q, sizeof (struct stroptions))) == NULL)
 781                 goto open_abort;
 782         tp->t_closeopts = bp;
 783 
 784         /*
 785          * Set the high-water and low-water marks on the stream head
 786          * to values appropriate for a terminal.  Also set the "vmin"
 787          * and "vtime" values to 1 and 0, turn on message-nondiscard
 788          * mode (as we're in ICANON mode), and turn on "old-style
 789          * NODELAY" mode.
 790          */
 791         if ((bp = open_mblk(q, sizeof (struct stroptions))) == NULL)
 792                 goto open_abort;
 793         strop = (struct stroptions *)bp->b_wptr;
 794         strop->so_flags = SO_READOPT|SO_HIWAT|SO_LOWAT|SO_NDELON|SO_ISTTY;
 795         strop->so_readopt = RMSGN;
 796         strop->so_hiwat = _TTY_BUFSIZ;
 797         strop->so_lowat = LOWAT;
 798         bp->b_wptr += sizeof (struct stroptions);
 799         bp->b_datap->db_type = M_SETOPTS;
 800         putnext(q, bp);
 801 
 802         return (0);             /* this can become a controlling TTY */
 803 
 804 open_abort:
 805         qprocsoff(q);
 806         q->q_ptr = NULL;
 807         WR(q)->q_ptr = NULL;
 808         freemsg(tp->t_closeopts);
 809         freemsg(tp->t_drainmsg);
 810         /* Dump the state structure */
 811         kmem_free(tp, sizeof (ldtermstd_state_t));
 812         return (EINTR);
 813 }
 814 
 815 struct close_timer {
 816         timeout_id_t id;


1878                                 bpt = NULL;
1879                                 *dofreep = 0;
1880                         } else {
1881                                 bpt = newmsg(tp);
1882                                 *dofreep = 1;
1883                         }
1884                         goto out;
1885                 }
1886         }
1887 
1888 escaped:
1889         /*
1890          * First, make sure we can fit one WHOLE multi-byte char in the
1891          * buffer.  This is one place where we have overhead even if
1892          * not in multi-byte mode; the overhead is subtracting
1893          * tp->t_maxeuc from MAX_CANON before checking.
1894          *
1895          * Allows MAX_CANON bytes in the buffer before throwing awaying
1896          * the the overflow of characters.
1897          */
1898         if ((tp->t_msglen > ((_TTY_BUFSIZ + 1) - (int)tp->t_maxeuc)) &&
1899             !((tp->t_state & TS_MEUC) && tp->t_eucleft)) {
1900 
1901                 /*
1902                  * Byte will cause line to overflow, or the next EUC
1903                  * won't fit: Ring the bell or discard all input, and
1904                  * don't save the byte away.
1905                  */
1906                 if (tp->t_modes.c_iflag & IMAXBEL) {
1907                         if (canputnext(wrq))
1908                                 ldterm_outchar(CTRL('g'), wrq, ebsize, tp);
1909                         goto out;
1910                 } else {
1911                         /*
1912                          * MAX_CANON processing. free everything in
1913                          * the current line and start with the
1914                          * current character as the first character.
1915                          */
1916                         DEBUG7(("ldterm_docanon: MAX_CANON processing\n"));
1917                         freemsg(tp->t_message);
1918                         tp->t_message = NULL;


4366                          */
4367                         tp->t_maxeuc = 0;    /* reset to say we're NOT */
4368 
4369                         tp->t_state &= ~TS_MEUC;
4370                         /*
4371                          * We'll set TS_MEUC if we're doing
4372                          * multi-column OR multi- byte OR both.  It
4373                          * makes things easier...  NOTE:  If we fail
4374                          * to get the buffer we need to hold display
4375                          * widths, then DON'T let the TS_MEUC bit get
4376                          * set!
4377                          */
4378                         for (i = 0; i < 4; i++) {
4379                                 if (tp->eucwioc.eucw[i] > tp->t_maxeuc)
4380                                         tp->t_maxeuc = tp->eucwioc.eucw[i];
4381                                 if (tp->eucwioc.scrw[i] > 1)
4382                                         tp->t_state |= TS_MEUC;
4383                         }
4384                         if ((tp->t_maxeuc > 1) || (tp->t_state & TS_MEUC)) {
4385                                 if (!tp->t_eucp_mp) {
4386                                         if ((tp->t_eucp_mp = allocb(_TTY_BUFSIZ,
4387                                             BPRI_HI)) == NULL) {
4388                                                 tp->t_maxeuc = 1;
4389                                                 tp->t_state &= ~TS_MEUC;
4390                                                 cmn_err(CE_WARN,
4391                                                     "Can't allocate eucp_mp");
4392                                                 miocnak(q, mp, 0, ENOSR);
4393                                                 return;
4394                                         }
4395                                         /*
4396                                          * here, if there's junk in
4397                                          * the canonical buffer, then
4398                                          * move the eucp pointer past
4399                                          * it, so we don't run off
4400                                          * the beginning.  This is a
4401                                          * total botch, but will
4402                                          * hopefully keep stuff from
4403                                          * getting too messed up
4404                                          * until the user flushes
4405                                          * this line!
4406                                          */
4407                                         if (tp->t_msglen) {


4595                                 return;
4596                         }
4597 
4598                         locale_name_sz = i + 1;
4599                 }
4600 
4601                 /*
4602                  * As the final check, if there was invalid codeset_type
4603                  * given, or invalid byte_length was specified, it's an error.
4604                  */
4605                 if (maxbytelen <= 0 || maxscreenlen <= 0) {
4606                         miocnak(q, mp, 0, ERANGE);
4607                         return;
4608                 }
4609 
4610                 /* Do the switching. */
4611                 tp->t_maxeuc = maxbytelen;
4612                 tp->t_state &= ~TS_MEUC;
4613                 if (maxbytelen > 1 || maxscreenlen > 1) {
4614                         if (!tp->t_eucp_mp) {
4615                                 if (!(tp->t_eucp_mp = allocb(_TTY_BUFSIZ,
4616                                     BPRI_HI))) {
4617                                         cmn_err(CE_WARN,
4618                                             "Can't allocate eucp_mp");
4619                                         miocnak(q, mp, 0, ENOSR);
4620                                         return;
4621                                 }
4622                                 /*
4623                                  * If there's junk in the canonical buffer,
4624                                  * then move the eucp pointer past it,
4625                                  * so we don't run off the beginning. This is
4626                                  * a total botch, but will hopefully keep
4627                                  * stuff from getting too messed up until
4628                                  * the user flushes this line!
4629                                  */
4630                                 if (tp->t_msglen) {
4631                                         tp->t_eucp = tp->t_eucp_mp->b_rptr;
4632                                         for (i = tp->t_msglen; i; i--)
4633                                                 *tp->t_eucp++ = 1;
4634                                 } else {
4635                                         tp->t_eucp = tp->t_eucp_mp->b_rptr;