mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Sync this properly.
This commit is contained in:
parent
a5830b9603
commit
3eb1bfddd4
@ -1,4 +1,4 @@
|
|||||||
/* $Id: buffer-poll.c,v 1.13 2009-06-25 16:21:32 nicm Exp $ */
|
/* $Id: buffer-poll.c,v 1.14 2009-06-25 16:22:36 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -23,29 +23,12 @@
|
|||||||
|
|
||||||
#include "tmux.h"
|
#include "tmux.h"
|
||||||
|
|
||||||
/* Set up pollfd for buffers. */
|
|
||||||
void
|
|
||||||
buffer_set(
|
|
||||||
struct pollfd *pfd, int fd, unused struct buffer *in, struct buffer *out)
|
|
||||||
{
|
|
||||||
pfd->fd = fd;
|
|
||||||
pfd->events = POLLIN;
|
|
||||||
if (BUFFER_USED(out) > 0)
|
|
||||||
pfd->events |= POLLOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill buffers from socket based on poll results. */
|
/* Fill buffers from socket based on poll results. */
|
||||||
int
|
int
|
||||||
buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
#if 0
|
|
||||||
log_debug("buffer_poll (%ld): fd=%d, revents=%d; out=%zu in=%zu",
|
|
||||||
(long) getpid(),
|
|
||||||
pfd->fd, pfd->revents, BUFFER_USED(out), BUFFER_USED(in));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_POLL
|
#ifdef HAVE_POLL
|
||||||
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
|
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -53,9 +36,6 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
|
|||||||
if (pfd->revents & POLLIN) {
|
if (pfd->revents & POLLIN) {
|
||||||
buffer_ensure(in, BUFSIZ);
|
buffer_ensure(in, BUFSIZ);
|
||||||
n = read(pfd->fd, BUFFER_IN(in), BUFFER_FREE(in));
|
n = read(pfd->fd, BUFFER_IN(in), BUFFER_FREE(in));
|
||||||
#if 0
|
|
||||||
log_debug("buffer_poll: fd=%d, read=%zd", pfd->fd, n);
|
|
||||||
#endif
|
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user