Some more research on the web suggests the Apple ships their operating

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.


git-svn-id: https://shellinabox.googlecode.com/svn/trunk@236 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
zodiac@gmail.com 2010-10-02 01:54:29 +00:00
parent 0c63f96f95
commit 2c2389fe30
7 changed files with 68 additions and 7 deletions

View file

@ -174,7 +174,7 @@
#define STDC_HEADERS 1 #define STDC_HEADERS 1
/* Most recent revision number in the version control system */ /* Most recent revision number in the version control system */
#define VCS_REVISION "235" #define VCS_REVISION "236"
/* Version number of package */ /* Version number of package */
#define VERSION "2.10" #define VERSION "2.10"

2
configure vendored
View file

@ -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 ac_compiler_gnu=$ac_cv_c_compiler_gnu
VCS_REVISION=235 VCS_REVISION=236
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF

View file

@ -2,7 +2,7 @@ AC_PREREQ(2.57)
dnl This is the one location where the authoritative version number is stored dnl This is the one location where the authoritative version number is stored
AC_INIT(shellinabox, 2.10, markus@shellinabox.com) AC_INIT(shellinabox, 2.10, markus@shellinabox.com)
VCS_REVISION=235 VCS_REVISION=236
AC_SUBST(VCS_REVISION) AC_SUBST(VCS_REVISION)
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}", AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
[Most recent revision number in the version control system]) [Most recent revision number in the version control system])

View file

@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = function() {
}; };
VT100.prototype.about = 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" + "\nCopyright 2008-2010 by Markus Gutschke\n" +
"For more information check http://shellinabox.com"); "For more information check http://shellinabox.com");
}; };

View file

@ -76,6 +76,67 @@
// API should be used, instead. // API should be used, instead.
#define MAX_PAYLOAD_LENGTH (64<<10) #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; time_t currentTime;
struct PayLoad { struct PayLoad {
@ -477,7 +538,7 @@ void serverLoop(struct Server *server) {
currentTime = time(&lastTime); currentTime = time(&lastTime);
int isTimeout = timeout >= 0 && int isTimeout = timeout >= 0 &&
timeout/1000 <= lastTime; timeout/1000 <= lastTime;
if (server->pollFds[0].revents) { if (eventCount > 0 && server->pollFds[0].revents) {
eventCount--; eventCount--;
if (server->pollFds[0].revents && POLLIN) { if (server->pollFds[0].revents && POLLIN) {
struct sockaddr_in clientAddr; struct sockaddr_in clientAddr;

View file

@ -358,7 +358,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
}; };
ShellInABox.prototype.about = function() { 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" + "\nCopyright 2008-2010 by Markus Gutschke\n" +
"For more information check http://shellinabox.com" + "For more information check http://shellinabox.com" +
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ? (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?

View file

@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = function() {
}; };
VT100.prototype.about = 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" + "\nCopyright 2008-2010 by Markus Gutschke\n" +
"For more information check http://shellinabox.com"); "For more information check http://shellinabox.com");
}; };