1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-29 22:40:34 +02:00

Fix POLLOUT assignment from port buffers

* libguile/poll.c (scm_primitive_poll): A buffered port's buffer marks
  it as writable only when writing a byte would not block, which is the
  case only if there is more than one byte free in the buffer; writing
  the last byte would block.
This commit is contained in:
Andy Wingo 2016-04-04 12:22:12 +02:00
parent b77fb752dd
commit 4bd9038925

View file

@ -111,8 +111,10 @@ scm_primitive_poll (SCM pollfds, SCM nfds, SCM ports, SCM timeout)
if (pt->read_pos < pt->read_end)
/* Buffered input waiting to be read. */
revents |= POLLIN;
if (pt->write_pos < pt->write_end)
/* Buffered output possible. */
if (SCM_OUTPUT_PORT_P (port)
&& pt->write_end - pt->write_pos > 1)
/* Buffered output possible. The "> 1" is because
writing the last byte would flush the port. */
revents |= POLLOUT;
}
}
@ -147,8 +149,10 @@ scm_primitive_poll (SCM pollfds, SCM nfds, SCM ports, SCM timeout)
if (pt->read_pos < pt->read_end)
/* Buffered input waiting to be read. */
revents |= POLLIN;
if (SCM_OUTPUT_PORT_P (port) && pt->write_pos < pt->write_end)
/* Buffered output possible. */
if (SCM_OUTPUT_PORT_P (port)
&& pt->write_end - pt->write_pos > 1)
/* Buffered output possible. The "> 1" is because
writing the last byte would flush the port. */
revents |= POLLOUT;
}
}