Add and use a DropClient() function for closing the diagnostic port.

Call DropClient() from Cleanup() too.
This commit is contained in:
Brian Somers 1997-11-18 00:19:34 +00:00
parent 2d404628d8
commit 3b7eb4fb00
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=31203
4 changed files with 30 additions and 35 deletions

View file

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: command.c,v 1.101 1997/11/12 18:47:28 brian Exp $
* $Id: command.c,v 1.102 1997/11/13 14:43:14 brian Exp $
*
*/
#include <sys/param.h>
@ -781,27 +781,12 @@ TerminalCommand(struct cmdtab const * list, int argc, char **argv)
static int
QuitCommand(struct cmdtab const * list, int argc, char **argv)
{
FILE *oVarTerm;
if (mode & MODE_INTER)
Cleanup(EX_NORMAL);
else if (argc > 0 && !strcasecmp(*argv, "all") &&
(VarLocalAuth & LOCAL_AUTH)) {
oVarTerm = VarTerm;
VarTerm = 0;
if (oVarTerm && oVarTerm != stdout)
fclose(oVarTerm);
close(netfd);
netfd = -1;
Cleanup(EX_NORMAL);
} else if (VarTerm) {
LogPrintf(LogPHASE, "Client connection closed.\n");
oVarTerm = VarTerm;
VarTerm = 0;
if (oVarTerm && oVarTerm != stdout)
fclose(oVarTerm);
close(netfd);
netfd = -1;
if (VarTerm) {
DropClient();
if (mode & MODE_INTER)
Cleanup(EX_NORMAL);
else if (argc > 0 && !strcasecmp(*argv, "all") && VarLocalAuth&LOCAL_AUTH)
Cleanup(EX_NORMAL);
}
return 0;

View file

@ -1,5 +1,5 @@
/*
* $Id: defs.c,v 1.2 1997/11/11 22:58:10 brian Exp $
* $Id: defs.c,v 1.3 1997/11/17 00:42:38 brian Exp $
*/
#include <sys/param.h>
@ -69,3 +69,19 @@ GetShortHost()
return 1;
}
void
DropClient()
{
FILE *oVarTerm;
if (VarTerm && !(mode & MODE_INTER)) {
oVarTerm = VarTerm;
VarTerm = 0;
if (oVarTerm)
fclose(oVarTerm);
close(netfd);
netfd = -1;
LogPrintf(LogPHASE, "Client connection closed.\n");
}
}

View file

@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: defs.h,v 1.25 1997/11/11 22:58:10 brian Exp $
* $Id: defs.h,v 1.26 1997/11/17 00:42:39 brian Exp $
*
* TODO:
*/
@ -91,3 +91,4 @@ extern void SetLabel(const char *);
extern const char *GetLabel(void);
extern void randinit(void);
extern int GetShortHost(void);
extern void DropClient(void);

View file

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: main.c,v 1.100 1997/11/17 00:42:40 brian Exp $
* $Id: main.c,v 1.101 1997/11/17 01:13:41 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@ -180,6 +180,7 @@ TtyOldMode()
void
Cleanup(int excode)
{
DropClient();
ServerClose();
OsInterfaceDown(1);
HangupModem(1);
@ -586,7 +587,6 @@ ReadTty()
int n;
char ch;
static int ttystate;
FILE *oVarTerm;
char linebuff[LINE_LEN];
LogPrintf(LogDEBUG, "termode = %d, netfd = %d, mode = %d\n",
@ -600,15 +600,8 @@ ReadTty()
if (n)
DecodeCommand(linebuff, n, IsInteractive(0) ? NULL : "Client");
Prompt();
} else {
LogPrintf(LogPHASE, "client connection closed.\n");
oVarTerm = VarTerm;
VarTerm = 0;
if (oVarTerm && oVarTerm != stdout)
fclose(oVarTerm);
close(netfd);
netfd = -1;
}
} else if (n < 0)
DropClient();
return;
}