On Wed, Aug 09, 2017 at 08:00:06PM +0200, Samuel Thibault wrote: > Okash Khawaja, on mar. 08 ao??t 2017 06:51:58 +0100, wrote: > > On Mon, Aug 07, 2017 at 11:18:44PM +0200, Samuel Thibault wrote: > > > > static void spk_ttyio_send_xchar(char ch) > > > > { > > > > + if (check_tty(speakup_tty)) > > > > + return; > > > > + > > > > speakup_tty->ops->send_xchar(speakup_tty, ch); > > > > } > > > > > > This is still unsafe: the unplug might come just between testing for > > > speakup_tty becoming NULL and using it. > > > > I thought about that but couldn't find a way to overcome it in a > > foolproof way. Here's my reasoning. Since the unplugging of usb is > > asynchronous to us calling methods on speakup_tty, speakup_tty can > > become null in a separate thread. > > Then more synchronization is needed: spk_ttyio_ldisc_close needs to > wait for methods to be finished calling. It would probably be enough > to introduce a mere mutex that would be taken around the uses of > speakup_tty, and in spk_ttyio_ldisc_close, so that it both waits for > uses of speakup_tty, and delay others from happening. I see what you mean. Thanks for clarifying. Okash _______________________________________________ Speakup mailing list Speakup@xxxxxxxxxxxxxxxxx http://linux-speakup.org/cgi-bin/mailman/listinfo/speakup