kernel: return error from sysrfork instead of waiting and retrying
The old strategy of wait and retry doesnt seem to work very well as it keeps all the forking parents stuck waiting in the kernel worsening the situation. The idea with this change is to have rfork() return error quickly; and without whining; as most callers would just react with a sysfatal() which might be better for surviving this.
This commit is contained in:
parent
b3c3c3e63d
commit
03d870e028
3 changed files with 8 additions and 12 deletions
|
@ -268,7 +268,7 @@ resrcwait(char *reason)
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if(up == nil)
|
if(up == nil)
|
||||||
panic("resrcwait");
|
panic("resrcwait: %s", reason);
|
||||||
|
|
||||||
p = up->psstate;
|
p = up->psstate;
|
||||||
if(reason != nil) {
|
if(reason != nil) {
|
||||||
|
|
|
@ -630,19 +630,13 @@ canpage(Proc *p)
|
||||||
Proc*
|
Proc*
|
||||||
newproc(void)
|
newproc(void)
|
||||||
{
|
{
|
||||||
char msg[64];
|
|
||||||
Proc *p;
|
Proc *p;
|
||||||
|
|
||||||
lock(&procalloc);
|
lock(&procalloc);
|
||||||
for(;;) {
|
p = procalloc.free;
|
||||||
if((p = procalloc.free) != nil)
|
if(p == nil){
|
||||||
break;
|
|
||||||
|
|
||||||
snprint(msg, sizeof msg, "no procs; %s forking",
|
|
||||||
up != nil ? up->text: "kernel");
|
|
||||||
unlock(&procalloc);
|
unlock(&procalloc);
|
||||||
resrcwait(msg);
|
return nil;
|
||||||
lock(&procalloc);
|
|
||||||
}
|
}
|
||||||
procalloc.free = p->qnext;
|
procalloc.free = p->qnext;
|
||||||
p->qnext = nil;
|
p->qnext = nil;
|
||||||
|
@ -1409,7 +1403,8 @@ kproc(char *name, void (*func)(void *), void *arg)
|
||||||
static Pgrp *kpgrp;
|
static Pgrp *kpgrp;
|
||||||
Proc *p;
|
Proc *p;
|
||||||
|
|
||||||
p = newproc();
|
while((p = newproc()) == nil)
|
||||||
|
resrcwait("no procs for kproc");
|
||||||
|
|
||||||
qlock(&p->debug);
|
qlock(&p->debug);
|
||||||
if(up != nil){
|
if(up != nil){
|
||||||
|
|
|
@ -84,7 +84,8 @@ sysrfork(va_list list)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = newproc();
|
if((p = newproc()) == nil)
|
||||||
|
error("no procs");
|
||||||
|
|
||||||
qlock(&p->debug);
|
qlock(&p->debug);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue