aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ndb
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-02-02 16:40:25 +0000
committerrsc <devnull@localhost>2006-02-02 16:40:25 +0000
commit387ae1dbb89dba0fc03ba5210b90bbde70a8cb86 (patch)
treead62d1209479dca4585c8c529b1a03a233fbd50e /src/cmd/ndb
parent40a2ff6f5d6291046a2bdeaa64de403a885a3a35 (diff)
downloadplan9port-387ae1dbb89dba0fc03ba5210b90bbde70a8cb86.tar.gz
plan9port-387ae1dbb89dba0fc03ba5210b90bbde70a8cb86.tar.bz2
plan9port-387ae1dbb89dba0fc03ba5210b90bbde70a8cb86.zip
fix fid handling
Diffstat (limited to 'src/cmd/ndb')
-rwxr-xr-xsrc/cmd/ndb/dns.c34
-rwxr-xr-xsrc/cmd/ndb/dns.h1
2 files changed, 30 insertions, 5 deletions
diff --git a/src/cmd/ndb/dns.c b/src/cmd/ndb/dns.c
index 5f509f24..17cde859 100755
--- a/src/cmd/ndb/dns.c
+++ b/src/cmd/ndb/dns.c
@@ -192,8 +192,8 @@ main(int argc, char *argv[])
srand(now*getpid());
db2cache(1);
- if(serve)
- proccreate(dnudpserver, mntpt, STACK);
+// if(serve)
+// proccreate(dnudpserver, mntpt, STACK);
if(sendnotifies)
notifyproc();
@@ -267,6 +267,10 @@ newfid(int fid, int needunused)
return mf;
}
}
+ if(!needunused){
+ unlock(&mfalloc.lk);
+ return nil;
+ }
mf = emalloc(sizeof(*mf));
if(mf == nil)
sysfatal("out of memory");
@@ -282,6 +286,7 @@ freefid(Mfile *mf)
{
Mfile **l;
+fprint(2, "freefid %d\n", mf->fid);
lock(&mfalloc.lk);
for(l = &mfalloc.inuse; *l != nil; l = &(*l)->next){
if(*l == mf){
@@ -385,13 +390,34 @@ io(void)
freejob(job);
continue;
}
- mf = newfid(job->request.fid, 0);
if(debug)
syslog(0, logfile, "%F", &job->request);
getactivity(&req);
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){
default:
syslog(1, logfile, "unknown request type %d", job->request.type);
@@ -436,7 +462,7 @@ io(void)
rwstat(job, mf);
break;
}
-
+skip:
freejob(job);
/*
diff --git a/src/cmd/ndb/dns.h b/src/cmd/ndb/dns.h
index bfaaa68d..0987f264 100755
--- a/src/cmd/ndb/dns.h
+++ b/src/cmd/ndb/dns.h
@@ -364,7 +364,6 @@ extern int mkreq(DN *dp, int type, uchar *buf, int flags, ushort reqno);
/* dnserver.c */
extern void dnserver(DNSmsg*, DNSmsg*, Request*);
-extern void dnudpserver(void*);
extern void dntcpserver(char*);
/* dnnotify.c */