pc kernel: kproc error and exit
catch the error() that can be thrown by sleep() and tsleep() in kprocs. add missing pexit() calls. always set the freemem argument to pexit() from kproc otherwise the process gets added to the broken list.
This commit is contained in:
parent
df6b68092c
commit
55d31f2cab
17 changed files with 89 additions and 27 deletions
|
@ -449,10 +449,13 @@ eventoccured(void)
|
|||
static void
|
||||
processevents(void *)
|
||||
{
|
||||
while (1) {
|
||||
int message;
|
||||
Cardbus *cb;
|
||||
int message;
|
||||
Cardbus *cb;
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
|
||||
for(;;){
|
||||
sleep(&revents, (int (*)(void *))eventoccured, nil);
|
||||
|
||||
cb = nil;
|
||||
|
|
|
@ -1228,18 +1228,19 @@ gc82543watchdog(void* arg)
|
|||
Ctlr *ctlr;
|
||||
|
||||
edev = arg;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
tsleep(&up->sleep, return0, 0, 1000);
|
||||
|
||||
ctlr = edev->ctlr;
|
||||
if(ctlr == nil){
|
||||
print("%s: exiting\n", up->text);
|
||||
pexit("disabled", 0);
|
||||
}
|
||||
if(ctlr == nil)
|
||||
break;
|
||||
|
||||
gc82543checklink(ctlr);
|
||||
gc82543replenish(ctlr);
|
||||
}
|
||||
print("%s: exiting\n", up->text);
|
||||
pexit("disabled", 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -348,6 +348,8 @@ watchdog(void* arg)
|
|||
static void txstart(Ether*);
|
||||
|
||||
ether = arg;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
tsleep(&up->sleep, return0, 0, 4000);
|
||||
|
||||
|
@ -357,10 +359,8 @@ watchdog(void* arg)
|
|||
* the future.
|
||||
*/
|
||||
ctlr = ether->ctlr;
|
||||
if(ctlr == nil || ctlr->state == 0){
|
||||
print("%s: exiting\n", up->text);
|
||||
pexit("disabled", 0);
|
||||
}
|
||||
if(ctlr == nil || ctlr->state == 0)
|
||||
break;
|
||||
|
||||
ilock(&ctlr->cblock);
|
||||
if(ctlr->tick++){
|
||||
|
@ -369,6 +369,8 @@ watchdog(void* arg)
|
|||
}
|
||||
iunlock(&ctlr->cblock);
|
||||
}
|
||||
print("%s: exiting\n", up->text);
|
||||
pexit("disabled", 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -853,6 +853,8 @@ i82563tproc(void *v)
|
|||
i82563txinit(ctlr);
|
||||
|
||||
tdt = ctlr->tdt;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
n = NEXT(tdt, ctlr->ntd);
|
||||
if(n == i82563cleanup(ctlr)){
|
||||
|
@ -986,6 +988,8 @@ i82563rproc(void *arg)
|
|||
}else
|
||||
im = Rxt0|Rxo|Rxdmt0|Rxseq|Ack;
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
i82563im(ctlr, im);
|
||||
ctlr->rsleep++;
|
||||
|
@ -1163,9 +1167,13 @@ phyl79proc(void *v)
|
|||
c = e->ctlr;
|
||||
|
||||
phyno = phyprobe(c, 3<<1);
|
||||
if(phyno == ~0)
|
||||
return;
|
||||
if(phyno == ~0){
|
||||
print("%s: no phy, exiting\n", up->text);
|
||||
pexit("no phy", 1);
|
||||
}
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
phy = phyread(c, phyno, Phystat);
|
||||
if(phy == ~0){
|
||||
|
@ -1203,11 +1211,16 @@ phylproc(void *v)
|
|||
c = e->ctlr;
|
||||
|
||||
phyno = phyprobe(c, 3<<1);
|
||||
if(phyno == ~0)
|
||||
return;
|
||||
if(phyno == ~0){
|
||||
print("%s: no phy, exiting\n", up->text);
|
||||
pexit("no phy", 1);
|
||||
}
|
||||
|
||||
if(c->type == i82573 && (phy = phyread(c, phyno, Phyier)) != ~0)
|
||||
phywrite(c, phyno, Phyier, phy | Lscie | Ancie | Spdie | Panie);
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
phy = phyread(c, phyno, Physsr);
|
||||
if(phy == ~0){
|
||||
|
@ -1263,6 +1276,8 @@ pcslproc(void *v)
|
|||
|
||||
if(c->type == i82575 || c->type == i82576)
|
||||
csr32w(c, Connsw, Enrgirq);
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
phy = csr32r(c, Pcsstat);
|
||||
e->link = phy & Linkok;
|
||||
|
@ -1290,6 +1305,8 @@ serdeslproc(void *v)
|
|||
e = v;
|
||||
c = e->ctlr;
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
rx = csr32r(c, Rxcw);
|
||||
tx = csr32r(c, Txcw);
|
||||
|
|
|
@ -375,6 +375,8 @@ lproc(void *v)
|
|||
|
||||
e = v;
|
||||
c = e->ctlr;
|
||||
while(waserror())
|
||||
;
|
||||
for (;;) {
|
||||
r = c->reg[Links];
|
||||
e->link = (r & Lnkup) != 0;
|
||||
|
@ -467,6 +469,8 @@ tproc(void *v)
|
|||
|
||||
e = v;
|
||||
c = e->ctlr;
|
||||
while(waserror())
|
||||
;
|
||||
for (;;) {
|
||||
sleep(&c->trendez, tim, c); /* transmit kicks us */
|
||||
c->tim = 0;
|
||||
|
@ -551,6 +555,8 @@ rproc(void *v)
|
|||
c = e->ctlr;
|
||||
m = c->nrd - 1;
|
||||
rdh = 0;
|
||||
while(waserror())
|
||||
;
|
||||
loop:
|
||||
replenish(c, rdh);
|
||||
im(c, Irx0);
|
||||
|
|
|
@ -782,6 +782,8 @@ igbelproc(void* arg)
|
|||
|
||||
edev = arg;
|
||||
ctlr = edev->ctlr;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
if(ctlr->mii == nil || ctlr->mii->curphy == nil)
|
||||
continue;
|
||||
|
@ -1091,6 +1093,9 @@ igberproc(void* arg)
|
|||
r |= Ren;
|
||||
csr32w(ctlr, Rctl, r);
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
|
||||
for(;;){
|
||||
ctlr->rim = 0;
|
||||
igbeim(ctlr, Rxt0|Rxo|Rxdmt0|Rxseq);
|
||||
|
|
|
@ -1997,11 +1997,10 @@ iwlrecover(void *arg)
|
|||
|
||||
edev = arg;
|
||||
ctlr = edev->ctlr;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
while(waserror())
|
||||
;
|
||||
tsleep(&up->sleep, return0, 0, 4000);
|
||||
poperror();
|
||||
|
||||
qlock(ctlr);
|
||||
for(;;){
|
||||
|
|
|
@ -1082,6 +1082,8 @@ m10rx(void *v)
|
|||
|
||||
e = v;
|
||||
c = e->ctlr;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
replenish(&c->sm);
|
||||
replenish(&c->bg);
|
||||
|
@ -1144,6 +1146,8 @@ txproc(void *v)
|
|||
e = v;
|
||||
c = e->ctlr;
|
||||
tx = &c->tx;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
sleep(&c->txrendez, txcansleep, c);
|
||||
txcleanup(tx, gbit32(c->stats->txcnt));
|
||||
|
|
|
@ -440,6 +440,8 @@ vt6102lproc(void* arg)
|
|||
|
||||
edev = arg;
|
||||
ctlr = edev->ctlr;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
if(ctlr->mii == nil || ctlr->mii->curphy == nil)
|
||||
break;
|
||||
|
|
|
@ -547,6 +547,8 @@ vt6105Mlproc(void* arg)
|
|||
|
||||
edev = arg;
|
||||
ctlr = edev->ctlr;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
if(ctlr->mii == nil || ctlr->mii->curphy == nil)
|
||||
break;
|
||||
|
|
|
@ -1243,6 +1243,8 @@ tproc(void *v)
|
|||
|
||||
txinit(e);
|
||||
linkup(c, Txen);
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
if((b = qbread(e->oq, 100000)) == nil)
|
||||
break;
|
||||
|
@ -1381,6 +1383,8 @@ rproc(void *v)
|
|||
|
||||
rxinit(e);
|
||||
linkup(c, Rxen);
|
||||
while(waserror())
|
||||
;
|
||||
for(;;)
|
||||
if(replenish(e, c) == 0){
|
||||
starve(k);
|
||||
|
@ -1750,7 +1754,8 @@ iproc(void *v)
|
|||
e = v;
|
||||
c = e->ctlr;
|
||||
k = &c->iproc;
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
starve(k);
|
||||
cause = c->reg[Eisr];
|
||||
|
|
|
@ -44,10 +44,11 @@ genrandom(void*)
|
|||
up->basepri = PriNormal;
|
||||
up->priority = up->basepri;
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
for(;;)
|
||||
if(++rb.randomcount > 100000)
|
||||
break;
|
||||
if(++rb.randomcount <= 100000)
|
||||
continue;
|
||||
if(anyhigher())
|
||||
sched();
|
||||
if(!rbnotfull(0))
|
||||
|
|
|
@ -1177,6 +1177,8 @@ satakproc(void*)
|
|||
{
|
||||
int i;
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
tsleep(&up->sleep, return0, 0, Nms);
|
||||
for(i = 0; i < niadrive; i++)
|
||||
|
|
|
@ -1100,6 +1100,8 @@ satakproc(void*)
|
|||
{
|
||||
int i;
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
tsleep(&up->sleep, return0, 0, Nms);
|
||||
for(i = 0; i < nmvsatadrive; i++)
|
||||
|
|
|
@ -2272,6 +2272,8 @@ mskproc(void*)
|
|||
{
|
||||
int i;
|
||||
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
tsleep(&up->sleep, return0, 0, Nms);
|
||||
for(i = 0; i < nmsdrive; i++)
|
||||
|
|
|
@ -682,6 +682,8 @@ w_timer(void* arg)
|
|||
Ctlr* ctlr = (Ctlr*)ether->ctlr;
|
||||
|
||||
ctlr->timerproc = up;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
tsleep(&up->sleep, return0, 0, MSperTick);
|
||||
ctlr = (Ctlr*)ether->ctlr;
|
||||
|
@ -732,7 +734,7 @@ w_timer(void* arg)
|
|||
}
|
||||
iunlock(ctlr);
|
||||
}
|
||||
pexit("terminated", 0);
|
||||
pexit("terminated", 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -450,9 +450,14 @@ wifiproc(void *arg)
|
|||
|
||||
b = nil;
|
||||
wifi = arg;
|
||||
while(waserror())
|
||||
;
|
||||
for(;;){
|
||||
if(b != nil)
|
||||
if(b != nil){
|
||||
freeb(b);
|
||||
b = nil;
|
||||
continue;
|
||||
}
|
||||
if((b = qbread(wifi->iq, 100000)) == nil)
|
||||
break;
|
||||
w = (Wifipkt*)b->rp;
|
||||
|
@ -526,7 +531,7 @@ wifiproc(void *arg)
|
|||
break;
|
||||
}
|
||||
}
|
||||
pexit("wifi in queue closed", 0);
|
||||
pexit("wifi in queue closed", 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -584,9 +589,11 @@ wifoproc(void *arg)
|
|||
|
||||
wifi = arg;
|
||||
ether = wifi->ether;
|
||||
while(waserror())
|
||||
;
|
||||
while((b = qbread(ether->oq, 1000000)) != nil)
|
||||
wifietheroq(wifi, b);
|
||||
pexit("ether out queue closed", 0);
|
||||
pexit("ether out queue closed", 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue