Avoid close error on FD_MASTER after DCD drop
This commit is contained in:
@@ -132,6 +132,12 @@ void _log_buf(int prio, const char *txt, const void *ptr_, unsigned int len)
|
||||
#define DBG2_BUF(txt, ptr, len) \
|
||||
if (ttynvt_param.debug > 1) _log_buf(LOG_DEBUG, txt, ptr, len)
|
||||
|
||||
static void _fd_close(int fd)
|
||||
{
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
static volatile char _is_interrupted = 0;
|
||||
|
||||
static void sig_handler(int sig)
|
||||
@@ -184,9 +190,9 @@ static void ttynvt_release(fuse_req_t req, struct fuse_file_info *info)
|
||||
_log(LOG_INFO, "connection closed\n");
|
||||
|
||||
tty->n_fds = 0;
|
||||
close(tty->fds[FD_NET].fd);
|
||||
close(tty->fds[FD_MASTER].fd);
|
||||
close(tty->fds[FD_SLAVE].fd);
|
||||
_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);
|
||||
@@ -556,8 +562,7 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
|
||||
ttynvt_param.host, ttynvt_param.port);
|
||||
|
||||
for (n = 0; n < 3; n++)
|
||||
if (tty->fds[n].fd >= 0)
|
||||
close(tty->fds[n].fd);
|
||||
_fd_close(tty->fds[n].fd);
|
||||
|
||||
free(tty->tn);
|
||||
free(tty);
|
||||
|
||||
Reference in New Issue
Block a user