[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 14/18: Fix POLLOUT assignment from port buffers
From: |
Andy Wingo |
Subject: |
[Guile-commits] 14/18: Fix POLLOUT assignment from port buffers |
Date: |
Wed, 06 Apr 2016 17:27:08 +0000 |
wingo pushed a commit to branch wip-port-refactor
in repository guile.
commit 4bd903892535b1b1ddb7a7b09895e85e96736745
Author: Andy Wingo <address@hidden>
Date: Mon Apr 4 12:22:12 2016 +0200
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.
---
libguile/poll.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/libguile/poll.c b/libguile/poll.c
index 9ea846b..90a5c05 100644
--- a/libguile/poll.c
+++ b/libguile/poll.c
@@ -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;
}
}
- [Guile-commits] branch wip-port-refactor created (now 8399e7a), Andy Wingo, 2016/04/06
- [Guile-commits] 08/18: Remove port equal functions, Andy Wingo, 2016/04/06
- [Guile-commits] 06/18: Remove port mark functions, Andy Wingo, 2016/04/06
- [Guile-commits] 14/18: Fix POLLOUT assignment from port buffers,
Andy Wingo <=
- [Guile-commits] 02/18: display-{application, -backtrace} delegate to Scheme, Andy Wingo, 2016/04/06
- [Guile-commits] 13/18: Flush buffered reads / writes before seeking, Andy Wingo, 2016/04/06
- [Guile-commits] 15/18: Cosmetic changes to vports.c, Andy Wingo, 2016/04/06
- [Guile-commits] 01/18: Fix frame->stack-vector when no stack is active, Andy Wingo, 2016/04/06
- [Guile-commits] 07/18: Remove port free functions; just close instead, Andy Wingo, 2016/04/06
- [Guile-commits] 16/18: When making soft port, parse handlers into struct, Andy Wingo, 2016/04/06
- [Guile-commits] 12/18: Whitespace fixes, Andy Wingo, 2016/04/06
- [Guile-commits] 05/18: Move line-buffing machinery to ports.c, Andy Wingo, 2016/04/06
- [Guile-commits] 10/18: Custom binary port internals refactor, Andy Wingo, 2016/04/06
- [Guile-commits] 04/18: Use symbols instead of _IONBF values as args to setvbuf, Andy Wingo, 2016/04/06