Bug 129701: removed the sleep command for Linux in kill_selfserv().

Instead, we try to bind to the port in a loop until the port has been
freed.  Added the -b (bindOnly) option to selfserv for this purpose.
Modified files: cmd/selfserv/selfserv.c tests/common/init.sh tests/ssl/ssl.sh
This commit is contained in:
wtc%netscape.com 2002-09-07 13:41:21 +00:00
Родитель f8534aaca7
Коммит ca133cf458
3 изменённых файлов: 27 добавлений и 9 удалений

Просмотреть файл

@ -172,13 +172,14 @@ Usage(const char *progName)
{
fprintf(stderr,
"Usage: %s -n rsa_nickname -p port [-3DRTmrvx] [-w password] [-t threads]\n"
"Usage: %s -n rsa_nickname -p port [-3DRTbmrvx] [-w password] [-t threads]\n"
" [-i pid_file] [-c ciphers] [-d dbdir] [-f fortezza_nickname] \n"
" [-M maxProcs] [-l]\n"
"-3 means disable SSL v3\n"
"-D means disable Nagle delays in TCP\n"
"-T means disable TLS\n"
"-R means disable detection of rollback from TLS to SSL3\n"
"-b means try binding to the port and exit\n"
"-m means test the model-socket feature of SSL_ImportFD.\n"
"-r flag is interepreted as follows:\n"
" 1 -r means request, not require, cert on initial handshake.\n"
@ -1408,6 +1409,7 @@ main(int argc, char **argv)
unsigned short port = 0;
SECStatus rv;
PRStatus prStatus;
PRBool bindOnly = PR_FALSE;
PRBool useExportPolicy = PR_FALSE;
PRBool useLocalThreads = PR_FALSE;
PLOptState *optstate;
@ -1438,7 +1440,7 @@ main(int argc, char **argv)
** numbers, then capital letters, then lower case, alphabetical.
*/
optstate = PL_CreateOptState(argc, argv,
"2:3DL:M:RTc:d:f:hi:lmn:op:rt:vw:xy");
"2:3DL:M:RTbc:d:f:hi:lmn:op:rt:vw:xy");
while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) {
++optionsFound;
switch(optstate->option) {
@ -1464,6 +1466,8 @@ main(int argc, char **argv)
case 'T': disableTLS = PR_TRUE; break;
case 'b': bindOnly = PR_TRUE; break;
case 'c': cipherString = strdup(optstate->value); break;
case 'd': dir = optstate->value; break;
@ -1519,6 +1523,19 @@ main(int argc, char **argv)
exit(51);
}
/* The -b (bindOnly) option is only used by the ssl.sh test
* script on Linux to determine whether a previous selfserv
* process has fully died and freed the port. (Bug 129701)
*/
if (bindOnly) {
listen_sock = getBoundListenSocket(port);
if (!listen_sock) {
exit(1);
}
PR_Close(listen_sock);
exit(0);
}
if ((nickName == NULL) && (fNickName == NULL)) {
fprintf(stderr, "Required arg '-n' (rsa nickname) not supplied.\n");
fprintf(stderr, "Run '%s -h' for usage information.\n", progName);

Просмотреть файл

@ -301,11 +301,6 @@ if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
tee ${LOGFILE}
KILL="kill"
if [ "${OS_ARCH}" = "Linux" ]; then
#on linux the selfserv needs up to 30 seconds to fully die and free
#the socket
SLEEP="sleep 30" # taking the chance and trying on the tinderboxes
fi
if [ `uname -s` = "SunOS" ]; then
PS="/usr/5bin/ps"
@ -431,7 +426,7 @@ if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
export PATH LD_LIBRARY_PATH SHLIB_PATH LIBPATH DYLD_LIBRARY_PATH
export DOMSUF HOSTADDR
export KILL SLEEP PS
export KILL PS
export MOZILLA_ROOT SECURITY_ROOT DIST TESTDIR OBJDIR HOSTDIR QADIR
export LOGFILE SCRIPTNAME

Просмотреть файл

@ -152,7 +152,13 @@ kill_selfserv()
if [ ${fileout} -eq 1 ]; then
cat ${SERVEROUTFILE}
fi
${SLEEP} #FIXME linux waits 30 seconds - find a shorter way (sockets free)
# On Linux selfserv needs up to 30 seconds to fully die and free
# the port. Wait until the port is free. (Bug 129701)
if [ "${OS_ARCH}" = "Linux" ]; then
until selfserv -b -p ${PORT} 2>/dev/null; do
sleep 1
done
fi
rm ${SERVERPID}
}