From e8c867345945f96c45fc4e60efe88b1822d179b7 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 14 Mar 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-03-14 --- port/devlance.c | 3 +++ port/devmnt.c | 34 ++++++++++++++++++++-------------- port/segment.c | 31 ++++++++++++------------------- port/tcptimer.c | 24 +++++++++++++----------- 4 files changed, 48 insertions(+), 44 deletions(-) diff --git a/port/devlance.c b/port/devlance.c index 414e9776096cfa8cbf27408f64db340617465713..c6380c6f4261edb20c2f676e4facc902be9daa69 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -431,6 +431,9 @@ lancestart(int mode, int dolock) Lancemem *lm = LANCEMEM; Msg *m; +if(mode == PROM) + print("setting promiscuous mode\n"); + /* * wait till both receiver and transmitter are * quiescent diff --git a/port/devmnt.c b/port/devmnt.c index 59c2bd3cb25881e3d5b45fc34bbe4046f72bb06b..412f04f9267b9b939329ae1fe3d7459e4dc0c477 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -186,14 +186,19 @@ mattach(Mnt *m, char *spec, char *serv) int i; r = mntralloc(); - c = devattach('M', spec); lock(&mntalloc); c->dev = mntalloc.id++; unlock(&mntalloc); c->mntindex = m-mntalloc.mntarena; - if(*serv && !waserror()){ + if(waserror()){ + mntfree(r); + close(c); + nexterror(); + } + + if(*serv){ r->request.type = Tauth; r->request.fid = c->fid; memmove(r->request.uname, u->p->user, NAMELEN); @@ -203,21 +208,22 @@ mattach(Mnt *m, char *spec, char *serv) memmove(r->request.chal, chal, 8); strncpy(r->request.chal+8, serv, NAMELEN); encrypt(u->p->pgrp->crypt->key, r->request.chal, 8+NAMELEN); - mountrpc(m, r); - decrypt(u->p->pgrp->crypt->key, r->reply.chal, 2*8+2*DESKEYLEN); - chal[0] = 4; - if(memcmp(chal, r->reply.chal, 8) != 0) - error(Eperm); - memmove(r->request.auth, r->reply.chal+8+DESKEYLEN, 8+DESKEYLEN); - poperror(); + if(waserror()) + memset(r->request.auth, 0, sizeof r->request.auth); + else{ + mountrpc(m, r); + poperror(); + decrypt(u->p->pgrp->crypt->key, r->reply.chal, 2*8+2*DESKEYLEN); + chal[0] = 4; + if(memcmp(chal, r->reply.chal, 8) != 0) + error(Eperm); + memmove(r->request.auth, r->reply.chal+8+DESKEYLEN, 8+DESKEYLEN); + } + r->done = 0; + r->flushed = 0; }else memset(r->request.auth, 0, sizeof r->request.auth); - if(waserror()){ - mntfree(r); - close(c); - nexterror(); - } r->request.type = Tattach; r->request.fid = c->fid; memmove(r->request.uname, u->p->user, NAMELEN); diff --git a/port/segment.c b/port/segment.c index 40687d5d3b301e6b813941b459ede0478fe5c337..b3b9cca44a65e2183d0b0d307b90bb2316ff3bc6 100644 --- a/port/segment.c +++ b/port/segment.c @@ -95,7 +95,9 @@ putseg(Segment *s) return; i = s->image; - if(i && i->s == s && s->ref == 1){ + if(i) + if(i->s == s) + if(s->ref == 1) { lock(i); if(s->ref == 1) i->s = 0; @@ -166,6 +168,7 @@ dupseg(Segment *s) n->image = s->image; n->fstart = s->fstart; n->flen = s->flen; + copypte: for(i = 0; i < SEGMAPSIZE; i++) if(pte = s->map[i]) @@ -272,30 +275,20 @@ imagereclaim(void) if(!canqlock(&ireclaim)) /* Somebody is already cleaning the page cache */ return; - if(conf.cntrlp) - print("ireclaim %lud\n", TK2MS(MACHP(0)->ticks)); - for(;;) { lock(&palloc); - for(p = palloc.head; p; p = p->next) + for(p = palloc.head; p; p = p->next) { if(p->image) if(p->ref == 0) - if(p->image != &swapimage) - break; - + if(p->image != &swapimage) { + lockpage(p); + if(p->ref == 0) + uncachepage(p); + unlockpage(p); + } + } unlock(&palloc); - if(p == 0) - break; - - lockpage(p); - if(p->ref == 0) - uncachepage(p); - unlockpage(p); } - - if(conf.cntrlp) - print("ireclaim done %lud\n", TK2MS(MACHP(0)->ticks)); - qunlock(&ireclaim); } diff --git a/port/tcptimer.c b/port/tcptimer.c index 50c2052f9661d607b2d358ce8e1ac52345650f8c..830a882ae3ac8ddfea70a6f02ee3a7eb200c4ea4 100644 --- a/port/tcptimer.c +++ b/port/tcptimer.c @@ -23,18 +23,14 @@ tcpackproc(void *junk) for(;;) { expired = 0; - /* Run through the list of running timers, decrementing each one. - * If one has expired, take it off the running list and put it - * on a singly linked list of expired timers - */ - qlock(&timerlock); for(t = timers;t != 0; t = tp) { tp = t->next; if(tp == t) panic("Timer loop at %lux\n",(long)tp); - if(t->state == TIMER_RUN && --(t->count) == 0){ + if(t->state == TIMER_RUN) + if(--(t->count) == 0){ /* Delete from active timer list */ if(timers == t) @@ -52,9 +48,14 @@ tcpackproc(void *junk) } qunlock(&timerlock); - while((t = expired) != 0){ + for(;;) { + t = expired; + if(t == 0) + break; + expired = t->next; - if(t->state == TIMER_EXPIRE && t->func) + if(t->state == TIMER_EXPIRE) + if(t->func) (*t->func)(t->arg); } @@ -118,9 +119,10 @@ tcpflow(void *conv) sleep(&tcpflowr, return0, 0); for(ifc = base; ifc < etab; ifc++) { - if(ifc->stproto == &tcpinfo && - ifc->ref != 0 && ifc->readq && - !QFULL(ifc->readq->next)) { + if(ifc->readq) + if(ifc->ref != 0) + if(ifc->stproto == &tcpinfo) + if(!QFULL(ifc->readq->next)) { tcprcvwin(ifc); tcp_acktimer(ifc); }