Skip to content

Commit

Permalink
The server could sometimes end up listening for events even though it
Browse files Browse the repository at this point in the history
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
  • Loading branch information
[email protected] committed Oct 2, 2010
1 parent 0ee4984 commit 1a33fc8
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
#define STDC_HEADERS 1

/* Most recent revision number in the version control system */
#define VCS_REVISION "237"
#define VCS_REVISION "238"

/* Version number of package */
#define VERSION "2.10"
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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=237
VCS_REVISION=238


cat >>confdefs.h <<_ACEOF
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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, [email protected])
VCS_REVISION=237
VCS_REVISION=238
AC_SUBST(VCS_REVISION)
AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
[Most recent revision number in the version control system])
Expand Down
2 changes: 1 addition & 1 deletion demo/vt100.js
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = 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" +
"For more information check http://shellinabox.com");
};
Expand Down
2 changes: 1 addition & 1 deletion libhttp/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ time_t serverGetTimeout(ServerConnection *connection);
ServerConnection *serverGetConnection(Server *server, ServerConnection *hint,
int fd);
short serverConnectionSetEvents(Server *server, ServerConnection *connection,
short events);
int fd, short events);
void serverExitLoop(Server *server, int exitAll);
void serverLoop(Server *server);
int serverSupportsSSL();
Expand Down
2 changes: 1 addition & 1 deletion libhttp/httpconnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ void httpTransfer(struct HttpConnection *http, char *msg, int len) {
if (!serverGetTimeout(connection)) {
serverSetTimeout(connection, CONNECTION_TIMEOUT);
}
serverConnectionSetEvents(http->server, connection,
serverConnectionSetEvents(http->server, connection, http->fd,
http->msgLength ? POLLIN|POLLOUT : POLLIN);
}
}
Expand Down
9 changes: 4 additions & 5 deletions libhttp/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ struct ServerConnection *serverGetConnection(struct Server *server,
}

short serverConnectionSetEvents(struct Server *server,
struct ServerConnection *connection,
struct ServerConnection *connection, int fd,
short events) {
dcheck(server);
dcheck(connection);
Expand All @@ -463,6 +463,7 @@ short serverConnectionSetEvents(struct Server *server,
dcheck(!connection->deleted);
int idx = connection - server->connections;
short oldEvents = server->pollFds[idx + 1].events;
dcheck(fd == server->pollFds[idx + 1].fd);
server->pollFds[idx + 1].events = events;
return oldEvents;
}
Expand Down Expand Up @@ -582,14 +583,12 @@ void serverLoop(struct Server *server) {
if (server->pollFds[i].revents) {
eventCount--;
}
short events = server->pollFds[i].events;
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->destroyConnection(connection->arg);
connection->deleted = 1;
} else {
server->pollFds[i].events = events;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion libhttp/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct ServerConnection *serverGetConnection(struct Server *server,
struct ServerConnection *hint,
int fd);
short serverConnectionSetEvents(struct Server *server,
struct ServerConnection *connection,
struct ServerConnection *connection, int fd,
short events);
void serverExitLoop(struct Server *server, int exitAll);
void serverLoop(struct Server *server);
Expand Down
2 changes: 1 addition & 1 deletion shellinabox/shell_in_a_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
};

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" +
"For more information check http://shellinabox.com" +
(typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
Expand Down
11 changes: 6 additions & 5 deletions shellinabox/shellinaboxd.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ static void sessionDone(void *arg) {
}

static int handleSession(struct ServerConnection *connection, void *arg,
short *events ATTR_UNUSED, short revents) {
UNUSED(events);
short *events, short revents) {
struct Session *session = (struct Session *)arg;
session->connection = connection;
int len = MAX_RESPONSE - session->len;
Expand Down Expand Up @@ -311,7 +310,7 @@ static int handleSession(struct ServerConnection *connection, void *arg,
session->pty);
session->connection = connection;
if (session->len >= MAX_RESPONSE) {
serverConnectionSetEvents(session->server, connection, 0);
*events = 0;
}
serverSetTimeout(connection, AJAX_TIMEOUT);
return 1;
Expand Down Expand Up @@ -460,13 +459,15 @@ static int dataHandler(HttpConnection *http, struct Service *service,
serverSetTimeout(session->connection, AJAX_TIMEOUT);
if (session->len < MAX_RESPONSE) {
// 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;
} else if (session->connection) {
// 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);
}

Expand Down
2 changes: 1 addition & 1 deletion shellinabox/vt100.js
Original file line number Diff line number Diff line change
Expand Up @@ -2402,7 +2402,7 @@ VT100.prototype.toggleCursorBlinking = 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" +
"For more information check http://shellinabox.com");
};
Expand Down

0 comments on commit 1a33fc8

Please sign in to comment.