diff --git a/ttynvt.c b/ttynvt.c index 224290e..eddd15d 100644 --- a/ttynvt.c +++ b/ttynvt.c @@ -65,7 +65,6 @@ typedef struct { char net_buf[NET_BUF_SIZE]; int net_cnt; - char tmp_buf[TMP_BUF_SIZE]; struct termios tio; @@ -226,6 +225,7 @@ static void _update_notify(ttynvt_t * tty, struct fuse_pollhandle *ph) static void *_read_net(void *arg) { ttynvt_t *tty = (ttynvt_t *) arg; + char buf[TMP_BUF_SIZE]; int res; pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); @@ -283,14 +283,14 @@ static void *_read_net(void *arg) if (tty->fds[FD_MASTER].revents & POLLIN) { - res = read(tty->fds[FD_MASTER].fd, tty->tmp_buf, TMP_BUF_SIZE); + res = read(tty->fds[FD_MASTER].fd, buf, TMP_BUF_SIZE); if (res < 0) { _log(LOG_ERR, "master read error: %m\n"); break; } - DBG2_BUF("TtyM in ", tty->tmp_buf, res); - telnet_tx(tty->tn, tty->tmp_buf, res); + DBG2_BUF("TtyM in ", buf, res); + telnet_tx(tty->tn, buf, res); } if (tty->fds[FD_SLAVE].revents & POLLIN) @@ -546,6 +546,7 @@ ttynvt_read(fuse_req_t req, size_t size, off_t off, struct fuse_file_info *info) { ttynvt_t *tty = (ttynvt_t *) (uintptr_t) info->fh; + char buf[TMP_BUF_SIZE]; int res; DBG2("%s\n", __func__); @@ -557,7 +558,7 @@ ttynvt_read(fuse_req_t req, size_t size, off_t off, { _log(LOG_WARNING, "Rx EPIPE\n"); tty->epipe = 1; - fuse_reply_buf(req, tty->tmp_buf, 0); + fuse_reply_buf(req, NULL, 0); } else fuse_reply_err(req, EBADFD); @@ -569,8 +570,7 @@ ttynvt_read(fuse_req_t req, size_t size, off_t off, size = TMP_BUF_SIZE; fuse_req_interrupt_func(req, ttynvt_interrupted, (void *)pthread_self()); - res = - _is_interrupted ? -2 : read(tty->fds[FD_SLAVE].fd, tty->tmp_buf, size); + res = _is_interrupted ? -2 : read(tty->fds[FD_SLAVE].fd, buf, size); _is_interrupted = 0; tty->n_fds = 3; /* Enable polling of Slave */ fuse_req_interrupt_func(req, NULL, NULL); @@ -582,9 +582,9 @@ ttynvt_read(fuse_req_t req, size_t size, off_t off, } DBG2("%s: fd=%d: sz=%u/%u: '%.*s'\n", __func__, - tty->fds[FD_SLAVE].fd, res, (int)size, res, tty->tmp_buf); + tty->fds[FD_SLAVE].fd, res, (int)size, res, buf); - fuse_reply_buf(req, tty->tmp_buf, res); + fuse_reply_buf(req, buf, res); } static void