Make -foreground a proper option (allowing ``allow mode foreground'',
``set mode foreground'' etc.
This commit is contained in:
parent
e9f0f7d4ad
commit
f6a4e748a9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53830
@ -966,7 +966,7 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
|
||||
/*
|
||||
* Our datalink has closed.
|
||||
* CleanDatalinks() (called from DoLoop()) will remove closed
|
||||
* BACKGROUND and DIRECT links.
|
||||
* BACKGROUND, FOREGROUND and DIRECT links.
|
||||
* If it's the last data link, enter phase DEAD.
|
||||
*
|
||||
* NOTE: dl may not be in our list (bundle_SendDatalink()) !
|
||||
@ -1282,7 +1282,8 @@ bundle_CleanDatalinks(struct bundle *bundle)
|
||||
|
||||
while (*dlp)
|
||||
if ((*dlp)->state == DATALINK_CLOSED &&
|
||||
(*dlp)->physical->type & (PHYS_DIRECT|PHYS_BACKGROUND)) {
|
||||
(*dlp)->physical->type &
|
||||
(PHYS_DIRECT|PHYS_BACKGROUND|PHYS_FOREGROUND)) {
|
||||
*dlp = datalink_Destroy(*dlp);
|
||||
found++;
|
||||
} else
|
||||
|
@ -249,13 +249,14 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
result = 0;
|
||||
switch (dl->state) {
|
||||
case DATALINK_CLOSED:
|
||||
if ((dl->physical->type &
|
||||
(PHYS_DIRECT|PHYS_DEDICATED|PHYS_BACKGROUND|PHYS_DDIAL)) &&
|
||||
if ((dl->physical->type & (PHYS_DIRECT|PHYS_DEDICATED|PHYS_BACKGROUND|
|
||||
PHYS_FOREGROUND|PHYS_DDIAL)) &&
|
||||
!dl->bundle->CleaningUp)
|
||||
/*
|
||||
* Our first time in - DEDICATED & DDIAL never come down, and
|
||||
* DIRECT & BACKGROUND get deleted when they enter DATALINK_CLOSED.
|
||||
* Go to DATALINK_OPENING via datalink_Up() and fall through.
|
||||
* DIRECT, FOREGROUND & BACKGROUND get deleted when they enter
|
||||
* DATALINK_CLOSED. Go to DATALINK_OPENING via datalink_Up()
|
||||
* and fall through.
|
||||
*/
|
||||
datalink_Up(dl, 1, 1);
|
||||
else
|
||||
@ -1410,7 +1411,8 @@ datalink_SetMode(struct datalink *dl, int mode)
|
||||
dl->script.run = 0;
|
||||
if (dl->physical->type == PHYS_DIRECT)
|
||||
dl->reconnect_tries = 0;
|
||||
if (mode & (PHYS_DDIAL|PHYS_BACKGROUND) && dl->state <= DATALINK_READY)
|
||||
if (mode & (PHYS_DDIAL|PHYS_BACKGROUND|PHYS_FOREGROUND) &&
|
||||
dl->state <= DATALINK_READY)
|
||||
datalink_Up(dl, 1, 1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ static struct {
|
||||
{ PHYS_DEDICATED, "dedicated" },
|
||||
{ PHYS_DDIAL, "ddial" },
|
||||
{ PHYS_BACKGROUND, "background" },
|
||||
{ PHYS_FOREGROUND, "foreground" },
|
||||
{ PHYS_ALL, "*" },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
@ -88,7 +88,8 @@
|
||||
#define PHYS_DEDICATED 8 /* Dedicated link */
|
||||
#define PHYS_DDIAL 16 /* Dial immediately, stay connected */
|
||||
#define PHYS_BACKGROUND 32 /* Dial immediately, deleted when closed */
|
||||
#define PHYS_ALL 63
|
||||
#define PHYS_FOREGROUND 64 /* Pseudo mode, same as background */
|
||||
#define PHYS_ALL 127
|
||||
|
||||
extern void randinit(void);
|
||||
extern ssize_t fullread(int, void *, size_t);
|
||||
|
@ -245,9 +245,6 @@ ProcessArgs(int argc, char **argv, struct switches *sw)
|
||||
} else if (strcmp(cp, "quiet") == 0) {
|
||||
sw->quiet = 1;
|
||||
optc--; /* this option isn't exclusive */
|
||||
} else if (strcmp(cp, "foreground") == 0) {
|
||||
sw->mode = PHYS_BACKGROUND; /* Kinda like background mode */
|
||||
sw->fg = 1;
|
||||
} else
|
||||
Usage();
|
||||
break;
|
||||
@ -258,6 +255,8 @@ ProcessArgs(int argc, char **argv, struct switches *sw)
|
||||
|
||||
default:
|
||||
sw->mode = newmode;
|
||||
if (newmode == PHYS_FOREGROUND)
|
||||
sw->fg = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -890,6 +890,7 @@ physical_SetMode(struct physical *p, int mode)
|
||||
if ((p->type & (PHYS_DIRECT|PHYS_DEDICATED) ||
|
||||
mode & (PHYS_DIRECT|PHYS_DEDICATED)) &&
|
||||
(!(p->type & PHYS_DIRECT) || !(mode & PHYS_BACKGROUND))) {
|
||||
/* Note: The -direct -> -background is for callback ! */
|
||||
log_Printf(LogWARN, "%s: Cannot change mode %s to %s\n", p->link.name,
|
||||
mode2Nam(p->type), mode2Nam(mode));
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user