The server could sometimes end up listening for events even though it

was not really interested in them. This could result in inefficient I/O
behavior and most noticably it broke the ability to interrupt long running
output with CTRL-C.


git-svn-id: https://shellinabox.googlecode.com/svn/trunk@238 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
zodiac@gmail.com 2010-10-02 23:40:24 +00:00
parent 0ee4984e2c
commit 1a33fc8127
11 changed files with 19 additions and 19 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 "237" #define VCS_REVISION "238"
/* 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=237 VCS_REVISION=238
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=237 VCS_REVISION=238
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 237)" + alert("VT100 Terminal Emulator " + "2.10 (revision 238)" +
"\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

@ -98,7 +98,7 @@ time_t serverGetTimeout(ServerConnection *connection);
ServerConnection *serverGetConnection(Server *server, ServerConnection *hint, ServerConnection *serverGetConnection(Server *server, ServerConnection *hint,
int fd); int fd);
short serverConnectionSetEvents(Server *server, ServerConnection *connection, short serverConnectionSetEvents(Server *server, ServerConnection *connection,
short events); int fd, short events);
void serverExitLoop(Server *server, int exitAll); void serverExitLoop(Server *server, int exitAll);
void serverLoop(Server *server); void serverLoop(Server *server);
int serverSupportsSSL(); int serverSupportsSSL();

View file

@ -768,7 +768,7 @@ void httpTransfer(struct HttpConnection *http, char *msg, int len) {
if (!serverGetTimeout(connection)) { if (!serverGetTimeout(connection)) {
serverSetTimeout(connection, CONNECTION_TIMEOUT); serverSetTimeout(connection, CONNECTION_TIMEOUT);
} }
serverConnectionSetEvents(http->server, connection, serverConnectionSetEvents(http->server, connection, http->fd,
http->msgLength ? POLLIN|POLLOUT : POLLIN); http->msgLength ? POLLIN|POLLOUT : POLLIN);
} }
} }

View file

@ -453,7 +453,7 @@ struct ServerConnection *serverGetConnection(struct Server *server,
} }
short serverConnectionSetEvents(struct Server *server, short serverConnectionSetEvents(struct Server *server,
struct ServerConnection *connection, struct ServerConnection *connection, int fd,
short events) { short events) {
dcheck(server); dcheck(server);
dcheck(connection); dcheck(connection);
@ -463,6 +463,7 @@ short serverConnectionSetEvents(struct Server *server,
dcheck(!connection->deleted); dcheck(!connection->deleted);
int idx = connection - server->connections; int idx = connection - server->connections;
short oldEvents = server->pollFds[idx + 1].events; short oldEvents = server->pollFds[idx + 1].events;
dcheck(fd == server->pollFds[idx + 1].fd);
server->pollFds[idx + 1].events = events; server->pollFds[idx + 1].events = events;
return oldEvents; return oldEvents;
} }
@ -582,14 +583,12 @@ void serverLoop(struct Server *server) {
if (server->pollFds[i].revents) { if (server->pollFds[i].revents) {
eventCount--; eventCount--;
} }
short events = server->pollFds[i].events;
if (!connection->handleConnection(connection, connection->arg, if (!connection->handleConnection(connection, connection->arg,
&events, server->pollFds[i].revents)){ &server->pollFds[i].events,
server->pollFds[i].revents)) {
connection = server->connections + i - 1; connection = server->connections + i - 1;
connection->destroyConnection(connection->arg); connection->destroyConnection(connection->arg);
connection->deleted = 1; connection->deleted = 1;
} else {
server->pollFds[i].events = events;
} }
} }
} }

View file

@ -109,7 +109,7 @@ struct ServerConnection *serverGetConnection(struct Server *server,
struct ServerConnection *hint, struct ServerConnection *hint,
int fd); int fd);
short serverConnectionSetEvents(struct Server *server, short serverConnectionSetEvents(struct Server *server,
struct ServerConnection *connection, struct ServerConnection *connection, int fd,
short events); short events);
void serverExitLoop(struct Server *server, int exitAll); void serverExitLoop(struct Server *server, int exitAll);
void serverLoop(struct Server *server); void serverLoop(struct Server *server);

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 237)" + alert("Shell In A Box version " + "2.10 (revision 238)" +
"\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

@ -282,8 +282,7 @@ static void sessionDone(void *arg) {
} }
static int handleSession(struct ServerConnection *connection, void *arg, static int handleSession(struct ServerConnection *connection, void *arg,
short *events ATTR_UNUSED, short revents) { short *events, short revents) {
UNUSED(events);
struct Session *session = (struct Session *)arg; struct Session *session = (struct Session *)arg;
session->connection = connection; session->connection = connection;
int len = MAX_RESPONSE - session->len; int len = MAX_RESPONSE - session->len;
@ -311,7 +310,7 @@ static int handleSession(struct ServerConnection *connection, void *arg,
session->pty); session->pty);
session->connection = connection; session->connection = connection;
if (session->len >= MAX_RESPONSE) { if (session->len >= MAX_RESPONSE) {
serverConnectionSetEvents(session->server, connection, 0); *events = 0;
} }
serverSetTimeout(connection, AJAX_TIMEOUT); serverSetTimeout(connection, AJAX_TIMEOUT);
return 1; return 1;
@ -460,13 +459,15 @@ static int dataHandler(HttpConnection *http, struct Service *service,
serverSetTimeout(session->connection, AJAX_TIMEOUT); serverSetTimeout(session->connection, AJAX_TIMEOUT);
if (session->len < MAX_RESPONSE) { if (session->len < MAX_RESPONSE) {
// Re-enable input on the child's pty // Re-enable input on the child's pty
serverConnectionSetEvents(session->server, session->connection,POLLIN); serverConnectionSetEvents(session->server, session->connection,
session->pty, POLLIN);
} }
} }
return HTTP_DONE; return HTTP_DONE;
} else if (session->connection) { } else if (session->connection) {
// Re-enable input on the child's pty // Re-enable input on the child's pty
serverConnectionSetEvents(session->server, session->connection, POLLIN); serverConnectionSetEvents(session->server, session->connection,
session->pty, POLLIN);
serverSetTimeout(session->connection, AJAX_TIMEOUT); serverSetTimeout(session->connection, AJAX_TIMEOUT);
} }

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 237)" + alert("VT100 Terminal Emulator " + "2.10 (revision 238)" +
"\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");
}; };