fix fid handling
This commit is contained in:
parent
40a2ff6f5d
commit
387ae1dbb8
2 changed files with 30 additions and 5 deletions
|
|
@ -192,8 +192,8 @@ main(int argc, char *argv[])
|
||||||
srand(now*getpid());
|
srand(now*getpid());
|
||||||
db2cache(1);
|
db2cache(1);
|
||||||
|
|
||||||
if(serve)
|
// if(serve)
|
||||||
proccreate(dnudpserver, mntpt, STACK);
|
// proccreate(dnudpserver, mntpt, STACK);
|
||||||
if(sendnotifies)
|
if(sendnotifies)
|
||||||
notifyproc();
|
notifyproc();
|
||||||
|
|
||||||
|
|
@ -267,6 +267,10 @@ newfid(int fid, int needunused)
|
||||||
return mf;
|
return mf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!needunused){
|
||||||
|
unlock(&mfalloc.lk);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
mf = emalloc(sizeof(*mf));
|
mf = emalloc(sizeof(*mf));
|
||||||
if(mf == nil)
|
if(mf == nil)
|
||||||
sysfatal("out of memory");
|
sysfatal("out of memory");
|
||||||
|
|
@ -282,6 +286,7 @@ freefid(Mfile *mf)
|
||||||
{
|
{
|
||||||
Mfile **l;
|
Mfile **l;
|
||||||
|
|
||||||
|
fprint(2, "freefid %d\n", mf->fid);
|
||||||
lock(&mfalloc.lk);
|
lock(&mfalloc.lk);
|
||||||
for(l = &mfalloc.inuse; *l != nil; l = &(*l)->next){
|
for(l = &mfalloc.inuse; *l != nil; l = &(*l)->next){
|
||||||
if(*l == mf){
|
if(*l == mf){
|
||||||
|
|
@ -385,13 +390,34 @@ io(void)
|
||||||
freejob(job);
|
freejob(job);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mf = newfid(job->request.fid, 0);
|
|
||||||
if(debug)
|
if(debug)
|
||||||
syslog(0, logfile, "%F", &job->request);
|
syslog(0, logfile, "%F", &job->request);
|
||||||
|
|
||||||
getactivity(&req);
|
getactivity(&req);
|
||||||
req.aborttime = now + 60; /* don't spend more than 60 seconds */
|
req.aborttime = now + 60; /* don't spend more than 60 seconds */
|
||||||
|
|
||||||
|
mf = nil;
|
||||||
|
switch(job->request.type){
|
||||||
|
case Tversion:
|
||||||
|
case Tauth:
|
||||||
|
case Tflush:
|
||||||
|
break;
|
||||||
|
case Tattach:
|
||||||
|
mf = newfid(job->request.fid, 1);
|
||||||
|
if(mf == nil){
|
||||||
|
sendmsg(job, "fid in use");
|
||||||
|
goto skip;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mf = newfid(job->request.fid, 0);
|
||||||
|
if(mf == nil){
|
||||||
|
sendmsg(job, "unknown fid");
|
||||||
|
goto skip;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch(job->request.type){
|
switch(job->request.type){
|
||||||
default:
|
default:
|
||||||
syslog(1, logfile, "unknown request type %d", job->request.type);
|
syslog(1, logfile, "unknown request type %d", job->request.type);
|
||||||
|
|
@ -436,7 +462,7 @@ io(void)
|
||||||
rwstat(job, mf);
|
rwstat(job, mf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
skip:
|
||||||
freejob(job);
|
freejob(job);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,6 @@ extern int mkreq(DN *dp, int type, uchar *buf, int flags, ushort reqno);
|
||||||
|
|
||||||
/* dnserver.c */
|
/* dnserver.c */
|
||||||
extern void dnserver(DNSmsg*, DNSmsg*, Request*);
|
extern void dnserver(DNSmsg*, DNSmsg*, Request*);
|
||||||
extern void dnudpserver(void*);
|
|
||||||
extern void dntcpserver(char*);
|
extern void dntcpserver(char*);
|
||||||
|
|
||||||
/* dnnotify.c */
|
/* dnnotify.c */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue