On Mon, Aug 31, 2015 at 09:07:07PM +0300, Cyrill Gorcunov wrote:
> On Mon, Aug 31, 2015 at 08:19:50PM +0300, Vladimir Davydov wrote:
> 
> OK, to all prev comments, thank you!
> 
> > > +         tty = tty_init_dev(vttys_driver, idx);
> > > +         if (IS_ERR(tty))
> > > +                 goto err_install;
> > 
> > So we have master:0 slave:1 here, right?
> 
> yes
> 
> > 
> > > +         tty->count--;
> > 
> > master:0 slave:0
> 
> yes
> 
> > 
> > > +         tty_unlock(tty);
> > > +         tty = tty->link;
> > > + }
> > > +
> > > + /* One master at a time */
> > > + if (tty->count >= 1) {
> > > +         ret = -EBUSY;
> > > +         goto err_install;
> > > + }
> > > +
> > > + vtty_drop_context();
> > > +
> > > + WARN_ON(!test_bit(TTY_LDISC, &tty->flags));
> > > +
> > > + /*
> > > +  * We're the master peer so increment
> > > +  * slave counter as well.
> > > +  */
> > > + tty_add_file(tty, file);
> > > + tty->count++;
> > 
> > If we just created the pair:
> >     master:1 slave:0
> > otherwise:
> >     master:1 slave:1+nusers
> 
>       master:1 slave:nusers, there is no additional +1 on it yet

Yeah, you're right. But then we diverge from pty ref counting design,
which isn't good IMO. To fix that, let's increment slave's count twice
on vtty_install, once for file and once for master reference. Then we
will only have to decrement slave's count right after tty_init_dev,
which is safe, because we're holding tty_lock there. Sounds OK?
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to