Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/a8bba72d2ac38cf32151a1b1d4967df4ab3ef8da
...commit
http://git.netsurf-browser.org/netsurf.git/commit/a8bba72d2ac38cf32151a1b1d4967df4ab3ef8da
...tree
http://git.netsurf-browser.org/netsurf.git/tree/a8bba72d2ac38cf32151a1b1d4967df4ab3ef8da
The branch, jmb/monkey-cc has been updated
via a8bba72d2ac38cf32151a1b1d4967df4ab3ef8da (commit)
from abdfdd65f93b49898e5c8acfdbc0f09f77865d49 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=a8bba72d2ac38cf32151a1b1d4967df4ab3ef8da
commit a8bba72d2ac38cf32151a1b1d4967df4ab3ef8da
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
monkey: fall back for non-POSIX select
Where a platform's select() implementation doesn't support use
with non-socket fds, we have a problem as we also cannot rely on
any of the other (semi-)portable methods for determining if stdin
has data pending in a non-blocking manner. Give up and block for
these -- note also that the full cost of the select() timeout will
be paid even if there is pending input (as select won't wake up).
diff --git a/frontends/monkey/main.c b/frontends/monkey/main.c
index fbc356c2f..2f0cbd91c 100644
--- a/frontends/monkey/main.c
+++ b/frontends/monkey/main.c
@@ -291,12 +291,14 @@ static void monkey_run(void)
/* clears fdset */
fetch_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
+#ifdef HAVE_POSIX_SELECT
/* add stdin to the set */
if (max_fd < 0) {
max_fd = STDIN_FILENO;
}
FD_SET(STDIN_FILENO, &read_fd_set);
FD_SET(STDIN_FILENO, &exc_fd_set);
+#endif
/* setup timeout */
switch (schedtm) {
@@ -304,6 +306,12 @@ static void monkey_run(void)
NSLOG(netsurf, INFO, "Iterate blocking");
moutf(MOUT_GENERIC, "POLL BLOCKING");
timeout = NULL;
+ if (max_fd < 0) {
+ /* No fds to select, so we need a timeout */
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+ timeout = &tv;
+ }
break;
case 0:
@@ -331,10 +339,26 @@ static void monkey_run(void)
NSLOG(netsurf, CRITICAL, "Unable to select: %s",
strerror(errno));
monkey_done = true;
} else if (rdy_fd > 0) {
+#ifdef HAVE_POSIX_SELECT
if (FD_ISSET(STDIN_FILENO, &read_fd_set)) {
monkey_process_command();
}
+#endif
}
+#ifndef HAVE_POSIX_SELECT
+ /* We cannot select() on non-socket fds, so we have
+ * no way of knowing whether there is input pending
+ * on stdin (and, unfortunately, none of the other
+ * common methods for determining stdin's readability
+ * in a non-blocking fashion are viable, either.
+ * Instead, if there were no active sockets and the
+ * next scheduled event time was many seconds away, read
+ * from stdin, anyway (and accept that this will block
+ * forever). */
+ if (max_fd < 0 && (schedtm == -1 || schedtm > 7500)) {
+ monkey_process_command();
+ }
+#endif
}
}
diff --git a/utils/config.h b/utils/config.h
index 3914771fd..f52f95c2d 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -102,9 +102,16 @@ char *strchrnul(const char *s, int c);
#define HAVE_SYS_SELECT
#define HAVE_POSIX_INET_HEADERS
+/* POSIX select() works with all fds; not just sockets */
+#define HAVE_POSIX_SELECT
#if (defined(_WIN32))
#undef HAVE_SYS_SELECT
#undef HAVE_POSIX_INET_HEADERS
+#undef HAVE_POSIX_SELECT
+#endif
+#if defined(__AMIGA__) || defined(__amigaos4__)
+/* select() on AmigaOS only works for sockets */
+#undef HAVE_POSIX_SELECT
#endif
#define HAVE_INETATON
-----------------------------------------------------------------------
Summary of changes:
frontends/monkey/main.c | 24 ++++++++++++++++++++++++
utils/config.h | 7 +++++++
2 files changed, 31 insertions(+)
diff --git a/frontends/monkey/main.c b/frontends/monkey/main.c
index fbc356c2f..2f0cbd91c 100644
--- a/frontends/monkey/main.c
+++ b/frontends/monkey/main.c
@@ -291,12 +291,14 @@ static void monkey_run(void)
/* clears fdset */
fetch_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd);
+#ifdef HAVE_POSIX_SELECT
/* add stdin to the set */
if (max_fd < 0) {
max_fd = STDIN_FILENO;
}
FD_SET(STDIN_FILENO, &read_fd_set);
FD_SET(STDIN_FILENO, &exc_fd_set);
+#endif
/* setup timeout */
switch (schedtm) {
@@ -304,6 +306,12 @@ static void monkey_run(void)
NSLOG(netsurf, INFO, "Iterate blocking");
moutf(MOUT_GENERIC, "POLL BLOCKING");
timeout = NULL;
+ if (max_fd < 0) {
+ /* No fds to select, so we need a timeout */
+ tv.tv_sec = 10;
+ tv.tv_usec = 0;
+ timeout = &tv;
+ }
break;
case 0:
@@ -331,10 +339,26 @@ static void monkey_run(void)
NSLOG(netsurf, CRITICAL, "Unable to select: %s",
strerror(errno));
monkey_done = true;
} else if (rdy_fd > 0) {
+#ifdef HAVE_POSIX_SELECT
if (FD_ISSET(STDIN_FILENO, &read_fd_set)) {
monkey_process_command();
}
+#endif
}
+#ifndef HAVE_POSIX_SELECT
+ /* We cannot select() on non-socket fds, so we have
+ * no way of knowing whether there is input pending
+ * on stdin (and, unfortunately, none of the other
+ * common methods for determining stdin's readability
+ * in a non-blocking fashion are viable, either.
+ * Instead, if there were no active sockets and the
+ * next scheduled event time was many seconds away, read
+ * from stdin, anyway (and accept that this will block
+ * forever). */
+ if (max_fd < 0 && (schedtm == -1 || schedtm > 7500)) {
+ monkey_process_command();
+ }
+#endif
}
}
diff --git a/utils/config.h b/utils/config.h
index 3914771fd..f52f95c2d 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -102,9 +102,16 @@ char *strchrnul(const char *s, int c);
#define HAVE_SYS_SELECT
#define HAVE_POSIX_INET_HEADERS
+/* POSIX select() works with all fds; not just sockets */
+#define HAVE_POSIX_SELECT
#if (defined(_WIN32))
#undef HAVE_SYS_SELECT
#undef HAVE_POSIX_INET_HEADERS
+#undef HAVE_POSIX_SELECT
+#endif
+#if defined(__AMIGA__) || defined(__amigaos4__)
+/* select() on AmigaOS only works for sockets */
+#undef HAVE_POSIX_SELECT
#endif
#define HAVE_INETATON
--
NetSurf Browser