]> andersk Git - test.git/commitdiff
Some more research on the web suggests the Apple ships their operating
authorMarkus Gutschke <markus@shellinabox.com>
Sat, 2 Oct 2010 01:54:29 +0000 (01:54 +0000)
committerMarkus Gutschke <markus@shellinabox.com>
Sat, 2 Oct 2010 01:54:29 +0000 (01:54 +0000)
systems with an implementation of poll() that isn't completely POSIX
compliant. We now fall back on calling select() instead. That's not our
first choice, but it is presumably the best that MacOS X can do.

config.h
configure
configure.ac
demo/vt100.js
libhttp/server.c
shellinabox/shell_in_a_box.js
shellinabox/vt100.js

index 2d281222ce32230d902d859c28c61b4c95f4f13d..8e63c44e0a4d811e9b27fad79dcc53f0357c92c7 100644 (file)
--- a/config.h
+++ b/config.h
 #define STDC_HEADERS 1
 
 /* Most recent revision number in the version control system */
-#define VCS_REVISION "235"
+#define VCS_REVISION "236"
 
 /* Version number of package */
 #define VERSION "2.10"
index 9329b65de229fc0e71d2fe83967bb3398a40d1b5..27505adefcb7f48b601babb99d170550d87c0bef 100755 (executable)
--- a/configure
+++ b/configure
@@ -2328,7 +2328,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-VCS_REVISION=235
+VCS_REVISION=236
 
 
 cat >>confdefs.h <<_ACEOF
index 72590dfaa82a75246c2116fb001e76190a5e8ec4..ae02914f1846f6da6d5dee6ab9d465cb865f387f 100644 (file)
@@ -2,7 +2,7 @@ AC_PREREQ(2.57)
 
 dnl This is the one location where the authoritative version number is stored
 AC_INIT(shellinabox, 2.10, markus@shellinabox.com)
-VCS_REVISION=235
+VCS_REVISION=236
 AC_SUBST(VCS_REVISION)
 AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
                    [Most recent revision number in the version control system])
index 74607e5a80b2f5cfa299a5988f03ca707a3c0976..cd02a14be53c6667bb0184bce693f74cf9863deb 100644 (file)
@@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = function() {
 };
 
 VT100.prototype.about = function() {
-  alert("VT100 Terminal Emulator " + "2.10 (revision 235)" +
+  alert("VT100 Terminal Emulator " + "2.10 (revision 236)" +
         "\nCopyright 2008-2010 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com");
 };
index d0ab1c7b0b87443804845cc596fb802b8656d0a9..b7e2d031babf5d4a745d8e5bd5a4a239f8ca297a 100644 (file)
 // API should be used, instead.
 #define MAX_PAYLOAD_LENGTH (64<<10)
 
+
+#if defined(__APPLE__) && defined(__MACH__)
+// While MacOS X does ship with an implementation of poll(), this
+// implementation is apparently known to be broken and does not comply
+// with POSIX standards. Fortunately, the operating system is not entirely
+// unable to check for input events. We can fall back on calling select()
+// instead. This is generally not desirable, as it is less efficient and
+// has a compile-time restriction on the maximum number of file
+// descriptors. But on MacOS X, that's the best we can do.
+
+int x_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
+  fd_set r, w, x;
+  FD_ZERO(&r);
+  FD_ZERO(&w);
+  FD_ZERO(&x);
+  int maxFd             = -1;
+  for (int i = 0; i < nfds; ++i) {
+    if (fds[i].fd > maxFd) {
+      maxFd = fds[i].fd;
+    } else if (fds[i].fd < 0) {
+      continue;
+    }
+    if (fds[i].events & POLLIN) {
+      FD_SET(fds[i].fd, &r);
+    }
+    if (fds[i].events & POLLOUT) {
+      FD_SET(fds[i].fd, &w);
+    }
+    if (fds[i].events & POLLPRI) {
+      FD_SET(fds[i].fd, &x);
+    }
+  }
+  struct timeval tmoVal = { 0 }, *tmo;
+  if (timeout < 0) {
+    tmo                 = NULL;
+  } else {
+    tmoVal.tv_sec       =  timeout / 1000;
+    tmoVal.tv_usec      = (timeout % 1000) * 1000;
+    tmo                 = &tmoVal;
+  }
+  int numRet            = select(maxFd + 1, &r, &w, &x, tmo);
+  for (int i = 0, n = numRet; i < nfds && n > 0; ++i) {
+    if (fds[i].fd < 0) {
+      continue;
+    }
+    if (FD_ISSET(fds[i].fd, &x)) {
+      fds[i].revents    = POLLPRI;
+    } else if (FD_ISSET(fds[i].fd, &r)) {
+      fds[i].revents    = POLLIN;
+    } else {
+      fds[i].revents    = 0;
+    }
+    if (FD_ISSET(fds[i].fd, &w)) {
+      fds[i].revents   |= POLLOUT;
+    }
+  }
+  return numRet;
+}
+#define poll x_poll
+#endif
+
 time_t currentTime;
 
 struct PayLoad {
@@ -477,7 +538,7 @@ void serverLoop(struct Server *server) {
     currentTime                           = time(&lastTime);
     int isTimeout                         = timeout >= 0 &&
                                             timeout/1000 <= lastTime;
-    if (server->pollFds[0].revents) {
+    if (eventCount > 0 && server->pollFds[0].revents) {
       eventCount--;
       if (server->pollFds[0].revents && POLLIN) {
         struct sockaddr_in clientAddr;
index c7acd3af14968f9fa70449bd266593271c971089..7a6e93e5e63ee6b22a01c6a16f1241173159e70a 100644 (file)
@@ -358,7 +358,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
 };
 
 ShellInABox.prototype.about = function() {
-  alert("Shell In A Box version " + "2.10 (revision 235)" +
+  alert("Shell In A Box version " + "2.10 (revision 236)" +
         "\nCopyright 2008-2010 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com" +
         (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
index 74607e5a80b2f5cfa299a5988f03ca707a3c0976..cd02a14be53c6667bb0184bce693f74cf9863deb 100644 (file)
@@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = function() {
 };
 
 VT100.prototype.about = function() {
-  alert("VT100 Terminal Emulator " + "2.10 (revision 235)" +
+  alert("VT100 Terminal Emulator " + "2.10 (revision 236)" +
         "\nCopyright 2008-2010 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com");
 };
This page took 0.150245 seconds and 5 git commands to generate.