Fixed a potential assertion failure in the daemon, if a user manages to type keys before he had a chance to establish a session.

git-svn-id: https://shellinabox.googlecode.com/svn/trunk@169 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
zodiac 2009-08-13 01:55:44 +00:00
parent bc811017fd
commit 5eade3daff
8 changed files with 57 additions and 8 deletions

View file

@ -138,7 +138,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 "168" #define VCS_REVISION "169"
/* Version number of package */ /* Version number of package */
#define VERSION "2.9" #define VERSION "2.9"

2
configure vendored
View file

@ -2317,7 +2317,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=168 VCS_REVISION=169
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.9, markus@shellinabox.com) AC_INIT(shellinabox, 2.9, markus@shellinabox.com)
VCS_REVISION=168 VCS_REVISION=169
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

@ -1829,7 +1829,7 @@ VT100.prototype.toggleBell = function() {
}; };
VT100.prototype.about = function() { VT100.prototype.about = function() {
alert("VT100 Terminal Emulator " + "2.9 (revision 168)" + alert("VT100 Terminal Emulator " + "2.9 (revision 169)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" + "\nCopyright 2008-2009 by Markus Gutschke\n" +
"For more information check http://shellinabox.com"); "For more information check http://shellinabox.com");
}; };

View file

@ -355,7 +355,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
}; };
ShellInABox.prototype.about = function() { ShellInABox.prototype.about = function() {
alert("Shell In A Box version " + "2.9 (revision 168)" + alert("Shell In A Box version " + "2.9 (revision 169)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" + "\nCopyright 2008-2009 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

@ -350,12 +350,17 @@ static int dataHandler(HttpConnection *http, struct Service *service,
// Create a new session, if the client did not provide an existing one // Create a new session, if the client did not provide an existing one
if (isNew) { if (isNew) {
if (cgiServer && cgiSessions++) { if (keys) {
serverExitLoop(cgiServer, 1); bad_new_session:
abandonSession(session); abandonSession(session);
httpSendReply(http, 400, "Bad Request", NO_MSG); httpSendReply(http, 400, "Bad Request", NO_MSG);
return HTTP_DONE; return HTTP_DONE;
} }
if (cgiServer && cgiSessions++) {
serverExitLoop(cgiServer, 1);
goto bad_new_session;
}
session->http = http; session->http = http;
if (launchChild(service->id, session) < 0) { if (launchChild(service->id, session) < 0) {
abandonSession(session); abandonSession(session);

View file

@ -1829,7 +1829,7 @@ VT100.prototype.toggleBell = function() {
}; };
VT100.prototype.about = function() { VT100.prototype.about = function() {
alert("VT100 Terminal Emulator " + "2.9 (revision 168)" + alert("VT100 Terminal Emulator " + "2.9 (revision 169)" +
"\nCopyright 2008-2009 by Markus Gutschke\n" + "\nCopyright 2008-2009 by Markus Gutschke\n" +
"For more information check http://shellinabox.com"); "For more information check http://shellinabox.com");
}; };

44
stresstest.sh Executable file
View file

@ -0,0 +1,44 @@
#!/bin/bash -e
PORT=4201
PIDFILE=stresstest.pid
rm -f "${PIDFILE}"
trap '[ -r "${PIDFILE}" ] && kill "$(cat "${PIDFILE}")"; rm -f "${PIDFILE}"' \
EXIT INT TERM QUIT HUP
./shellinaboxd -p "${PORT}" -s "/:$(id -u):$(id -g):${PWD}:/bin/bash -c \
'while read i; do [ -z "${i}" ] && break; echo \" $i\"; done'" \
--background="${PIDFILE}"
session() {
local data="$(wget -O- --post-data='' --quiet "http://localhost:${PORT}/")"
local session="${data##*\"session\":\"}"
session="${session%%\"*}"
while read -r i; do
local keys="$(echo -n "${i}" | od -tx1 -An -w1000)"
wget -O/dev/null --post-data="session=${session}&keys=${keys// /}" \
--quiet "http://localhost:${PORT}/"
kill -0 "$(cat "${PIDFILE}")" || break
[ -z "$i" ] && break
data="$(wget -O- --post-data="session=${session}" \
--quiet "http://localhost:${PORT}/")"
data=${data##*\"data\":\"}
data=${data%%\"*}
echo "${data}"
done <<'EOF'
Hello world
This is a test
OK, that's it for now
EOF
}
pids=""
for i in `seq 100`; do
session &
pids="${pids} $!"
sleep 0.02
kill -0 "$(cat "${PIDFILE}")" || break
done
wait $pids >&/dev/null