M port/devlance.c => port/devlance.c +3 -0
@@ 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
M port/devmnt.c => port/devmnt.c +20 -14
@@ 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);
M port/segment.c => port/segment.c +12 -19
@@ 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);
}
M port/tcptimer.c => port/tcptimer.c +13 -11
@@ 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);
}