Avoid close error on FD_MASTER after DCD drop

This commit is contained in:
Kim Woelders
2018-10-25 07:42:08 +02:00
parent 0cc9b58a65
commit 0f95e0779e
+10 -5
View File
@@ -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);