Updates for mbtask
This commit is contained in:
@@ -49,6 +49,8 @@ extern _alist_l *alist; /* Nodes to call list */
|
||||
extern int pots_calls;
|
||||
extern int isdn_calls;
|
||||
extern int inet_calls;
|
||||
extern int pots_lines; /* POTS lines available */
|
||||
extern int isdn_lines; /* ISDN lines available */
|
||||
extern struct taskrec TCFG;
|
||||
|
||||
|
||||
@@ -85,7 +87,7 @@ int check_calllist(void)
|
||||
call_work = 0;
|
||||
for (tmp = alist; tmp; tmp = tmp->next) {
|
||||
if (((tmp->callmode == CM_INET) && TCFG.max_tcp && internet) ||
|
||||
((tmp->callmode == CM_ISDN) && TCFG.max_isdn) || ((tmp->callmode == CM_POTS) && TCFG.max_pots)) {
|
||||
((tmp->callmode == CM_ISDN) && isdn_lines) || ((tmp->callmode == CM_POTS) && pots_lines)) {
|
||||
call_work++;
|
||||
|
||||
/*
|
||||
|
@@ -96,6 +96,10 @@ int rescan = FALSE; /* Master rescan flag */
|
||||
extern int pots_calls;
|
||||
extern int isdn_calls;
|
||||
extern int inet_calls;
|
||||
extern int pots_lines; /* POTS lines available */
|
||||
extern int isdn_lines; /* ISDN lines available */
|
||||
extern int pots_free; /* POTS lines free */
|
||||
extern int isdn_free; /* ISDN lines free */
|
||||
|
||||
|
||||
|
||||
@@ -423,10 +427,7 @@ void load_taskcfg(void)
|
||||
sprintf(TCFG.cmd_mbindex2, "%s/bin/goldnode -f -q", getenv("MBSE_ROOT"));
|
||||
sprintf(TCFG.cmd_msglink, "%s/bin/mbmsg link -quiet", getenv("MBSE_ROOT"));
|
||||
sprintf(TCFG.cmd_reqindex, "%s/bin/mbfile index -quiet", getenv("MBSE_ROOT"));
|
||||
TCFG.ipblocks = TRUE;
|
||||
TCFG.debug = FALSE;
|
||||
TCFG.max_pots = 1;
|
||||
TCFG.max_isdn = 0;
|
||||
TCFG.max_tcp = 0;
|
||||
sprintf(TCFG.isp_ping1, "192.168.1.1");
|
||||
sprintf(TCFG.isp_ping2, "192.168.1.1");
|
||||
@@ -902,6 +903,9 @@ void scheduler(void)
|
||||
|
||||
initnl();
|
||||
sem_set((char *)"scanout", TRUE);
|
||||
if (!TCFG.max_tcp && !pots_lines && !isdn_lines) {
|
||||
tasklog('?', "ERROR: this system cannot connect to other systems, check setup");
|
||||
}
|
||||
|
||||
/*
|
||||
* Enter the mainloop (forever)
|
||||
@@ -1157,11 +1161,11 @@ void scheduler(void)
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
if ((calllist[call_entry].callmode == CM_ISDN) && (runtasktype(CM_ISDN) < TCFG.max_isdn)) {
|
||||
if ((calllist[call_entry].callmode == CM_ISDN) && (runtasktype(CM_ISDN) < isdn_free)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
if ((calllist[call_entry].callmode == CM_POTS) && (runtasktype(CM_POTS) < TCFG.max_pots)) {
|
||||
if ((calllist[call_entry].callmode == CM_POTS) && (runtasktype(CM_POTS) < pots_free)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -1176,6 +1180,11 @@ void scheduler(void)
|
||||
}
|
||||
if (found) {
|
||||
// tasklog('c', "Should launch slot %d node %s", call_entry, ascfnode(calllist[call_entry].addr, 0x1f));
|
||||
/*
|
||||
* FIXME: here we should check if there are multiple ISDN or POTS lines which of the
|
||||
* lines matches the flags to call that node and use the most simple device.
|
||||
* The mbcico should be called with the instruction which line to use.
|
||||
*/
|
||||
cmd = xstrcpy(pw->pw_dir);
|
||||
cmd = xstrcat(cmd, (char *)"/bin/mbcico");
|
||||
sprintf(opts, "f%u.n%u.z%u", calllist[call_entry].addr.node, calllist[call_entry].addr.net,
|
||||
|
@@ -48,6 +48,8 @@ int isdn_calls; /* ISDN calls to make */
|
||||
int pots_calls; /* POTS calls to make */
|
||||
_alist_l *alist = NULL; /* Nodes to call list */
|
||||
extern int s_do_inet; /* Internet wanted */
|
||||
extern int pots_lines; /* POTS lines available */
|
||||
extern int isdn_lines; /* ISDN lines available */
|
||||
|
||||
|
||||
|
||||
@@ -389,7 +391,7 @@ int outstat()
|
||||
tmp->callmode = CM_INET;
|
||||
}
|
||||
|
||||
if ((tmp->callmode == CM_NONE) && TCFG.max_isdn) {
|
||||
if ((tmp->callmode == CM_NONE) && isdn_lines) {
|
||||
/*
|
||||
* ISDN node
|
||||
*/
|
||||
@@ -398,7 +400,7 @@ int outstat()
|
||||
break;
|
||||
}
|
||||
|
||||
if ((tmp->callmode == CM_NONE) && TCFG.max_pots) {
|
||||
if ((tmp->callmode == CM_NONE) && pots_lines) {
|
||||
/*
|
||||
* POTS node
|
||||
*/
|
||||
@@ -406,6 +408,13 @@ int outstat()
|
||||
tmp->callmode = CM_POTS;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we are out of options.
|
||||
*/
|
||||
if (tmp->callmode == CM_NONE) {
|
||||
tasklog('!', "No method to call %s available", ascfnode(tmp->addr, 0x0f));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -52,6 +52,11 @@ extern time_t tty_time; /* TTY update time */
|
||||
extern int rescan; /* Master rescan flag */
|
||||
pp_list *pl = NULL; /* Portlist */
|
||||
|
||||
int pots_lines = 0; /* POTS (Modem) lines */
|
||||
int isdn_lines = 0; /* ISDN lines */
|
||||
int pots_free = 0; /* POTS (Modem) lines free */
|
||||
int isdn_free = 0; /* ISDN lines free */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -106,7 +111,7 @@ void load_ports()
|
||||
{
|
||||
FILE *fp;
|
||||
pp_list new;
|
||||
int count = 0, j, stdflag;
|
||||
int j, stdflag;
|
||||
char *p, *q;
|
||||
|
||||
tidy_portlist(&pl);
|
||||
@@ -117,8 +122,16 @@ void load_ports()
|
||||
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, fp);
|
||||
|
||||
tasklog('p', "Building portlist...");
|
||||
pots_lines = isdn_lines = 0;
|
||||
|
||||
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, fp) == 1) {
|
||||
if (((ttyinfo.type == POTS) || (ttyinfo.type == ISDN)) && (ttyinfo.available) && (ttyinfo.callout)) {
|
||||
|
||||
if (ttyinfo.type == POTS)
|
||||
pots_lines++;
|
||||
if (ttyinfo.type == ISDN)
|
||||
isdn_lines++;
|
||||
|
||||
memset(&new, 0, sizeof(new));
|
||||
strncpy(new.tty, ttyinfo.tty, 6);
|
||||
|
||||
@@ -138,14 +151,15 @@ void load_ports()
|
||||
new.dflags |= dkey[j].flag;
|
||||
}
|
||||
}
|
||||
|
||||
tasklog('p', "port %s modem %08lx ISDN %08lx", new.tty, new.mflags, new.dflags);
|
||||
fill_portlist(&pl, &new);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
tty_time = file_time(ttyfn);
|
||||
tasklog('p', "make_portlist %d ports", count);
|
||||
tasklog('+', "Detected %d modem ports and %d ISDN ports", pots_lines, isdn_lines);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,12 +173,13 @@ void check_ports(void)
|
||||
pp_list *tpl;
|
||||
char lckname[256];
|
||||
FILE *lf;
|
||||
int tmppid;
|
||||
int tmppid, changed = FALSE;
|
||||
pid_t rempid = 0;
|
||||
|
||||
pots_free = isdn_free = 0;
|
||||
|
||||
for (tpl = pl; tpl; tpl = tpl->next) {
|
||||
sprintf(lckname, "%s%s", LCKPREFIX, tpl->tty);
|
||||
// tasklog('p', "checking %s", lckname);
|
||||
if ((lf = fopen(lckname, "r")) == NULL) {
|
||||
if (tpl->locked) {
|
||||
tpl->locked = 0;
|
||||
@@ -172,7 +187,7 @@ void check_ports(void)
|
||||
/*
|
||||
* Good, set master rescan flag
|
||||
*/
|
||||
rescan = TRUE;
|
||||
changed = TRUE;
|
||||
}
|
||||
} else {
|
||||
fscanf(lf, "%d", &tmppid);
|
||||
@@ -181,15 +196,28 @@ void check_ports(void)
|
||||
if (kill(rempid, 0) && (errno == ESRCH)) {
|
||||
tasklog('+', "Stale lockfile for %s, unlink", tpl->tty);
|
||||
unlink(lckname);
|
||||
rescan = TRUE;
|
||||
changed = TRUE;
|
||||
} else {
|
||||
if (!tpl->locked) {
|
||||
tpl->locked = rempid;
|
||||
tasklog('+', "Port %s locked, pid %d", tpl->tty, rempid);
|
||||
rescan = TRUE;
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now count free ports
|
||||
*/
|
||||
if (tpl->mflags && !tpl->locked)
|
||||
pots_free++;
|
||||
if (tpl->dflags && !tpl->locked)
|
||||
isdn_free++;
|
||||
|
||||
if (changed) {
|
||||
rescan = TRUE;
|
||||
tasklog('p', "Free ports: pots=%d isdn=%d", pots_free, isdn_free);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user