ttynvt: Avoid potential "net read error" in _read_net() when closing
ttynvt_release() may be called when the poll thread is blocked in a read(FD_NET) (maybe also read(FD_MASTER) - not sure). So ttynvt_release() sets rel_pending before closing the fd, but too late as the read() will return an error when the fd is closed, and before the thread is cancelled. Now we cancel/join the thread before closing the file descriptor(s).
This commit is contained in:
+4
-3
@@ -141,15 +141,16 @@ static void ttynvt_release(fuse_req_t req, struct fuse_file_info *info)
|
||||
DBG("%s\n", __func__);
|
||||
|
||||
tty->rel_pending = 1;
|
||||
_fd_close(tty->fds[FD_NET].fd);
|
||||
_fd_close(tty->fds[FD_MASTER].fd);
|
||||
_fd_close(tty->fds[FD_SLAVE].fd);
|
||||
|
||||
pthread_cancel(tty->ptid_poll);
|
||||
pthread_join(tty->ptid_poll, NULL);
|
||||
pthread_mutex_destroy(&tty->tty_lock);
|
||||
pthread_mutex_destroy(&tty->poll_lock);
|
||||
|
||||
_fd_close(tty->fds[FD_NET].fd);
|
||||
_fd_close(tty->fds[FD_MASTER].fd);
|
||||
_fd_close(tty->fds[FD_SLAVE].fd);
|
||||
|
||||
if (tty->ph)
|
||||
fuse_pollhandle_destroy(tty->ph);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user