From faf1415d45c238b38d182e083c778ac361f7a610 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 24 Jul 1998 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1998-07-24 --- ip/il.c | 2 +- ip/tcp.c | 11 +++++++---- port/devmnt.c | 5 +++-- port/proc.c | 2 +- port/segment.c | 21 +++++++++++++++++---- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/ip/il.c b/ip/il.c index 11b7ae73f21c88914e0e0e64dab85c2a01615f35..64d1d96bb1a8f1d47a8c0d81fa2fedab78986c84 100644 --- a/ip/il.c +++ b/ip/il.c @@ -201,7 +201,7 @@ ilstate(Conv *c, char *state, int n) Ilcb *ic; ic = (Ilcb*)(c->ptcl); - return snprint(state, n, "%14.14s del %5.5d Br %5.5d md %5.5d una %5.5d rex %5.5d max %5.5d", + return snprint(state, n, "%s del %5.5d Br %5.5d md %5.5d una %5.5d rex %5.5d max %5.5d", ilstates[ic->state], ic->delay>>LogAGain, ic->rate>>LogAGain, ic->mdev>>LogDGain, ic->unackeduchars, ic->rexmit, ic->maxrtt); diff --git a/ip/tcp.c b/ip/tcp.c index bb2ad2180066b4dea96f11ce96d2dc412efc3e08..d01d3be21b51252b59c4910d4a53bfa4a598711d 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -266,9 +266,9 @@ tcpsetstate(Conv *s, uchar newstate) qclose(s->rq); qclose(s->wq); qclose(s->eq); - s->lport = 0; /* This connection is toast */ - s->rport = 0; - ipmove(s->raddr, IPnoaddr); +// s->lport = 0; /* This connection is toast */ +// s->rport = 0; +// ipmove(s->raddr, IPnoaddr); case Close_wait: /* Remote closes */ qhangup(s->rq, nil); @@ -1138,8 +1138,10 @@ tcpiput(Proto *tcp, uchar*, Block *bp) /* Look for a connection. failing that look for a listener. */ for(p = tcp->conv; *p; p++) { s = *p; + tcb = (Tcpctl*)s->ptcl; if(s->rport == seg.source) if(s->lport == seg.dest) + if(tcb->state != Closed) if(ipcmp(s->raddr, source) == 0) break; } @@ -1931,11 +1933,12 @@ tcpadvise(Proto *tcp, Block *bp, char *msg) /* Look for a connection */ for(p = tcp->conv; *p; p++) { s = *p; + tcb = (Tcpctl*)s->ptcl; if(s->rport == pdest) if(s->lport == psource) + if(tcb->state != Closed) if(ipcmp(s->raddr, dest) == 0) if(ipcmp(s->laddr, source) == 0){ - tcb = (Tcpctl*)s->ptcl; qlock(tcb); switch(tcb->state){ case Syn_sent: diff --git a/port/devmnt.c b/port/devmnt.c index a62ba5c7f3436a65a1669e60ff40cb31f8ce1868..983e7ae4992886fad5a6099bb14da75fe1bbc4e6 100644 --- a/port/devmnt.c +++ b/port/devmnt.c @@ -1024,7 +1024,7 @@ mntrepl(char *buf) int fd; Mnt *m; char *p; - Chan *c1; + Chan *c1, *c2; Mntrpc *r; /* reply from boot is 'fd #M23' */ @@ -1046,7 +1046,7 @@ mntrepl(char *buf) srvrecover(m->c, c1); lock(m); - cclose(m->c); + c2 = m->c; m->c = c1; m->recprog = 0; @@ -1055,6 +1055,7 @@ mntrepl(char *buf) wakeup(&r->r); unlock(m); + cclose(c2); } Dev mntdevtab = { diff --git a/port/proc.c b/port/proc.c index e40c1179f9fee8f6b90fef99cb99801fb6437351..b8b9b15cbfcb1585b883d2655c4e58adb4f9761b 100644 --- a/port/proc.c +++ b/port/proc.c @@ -384,7 +384,7 @@ procinit0(void) /* bad planning - clashes with devproc.c */ /* * Sleep, postnote, and wakeup are complicated by the - * fact that they at least one of them must indirect + * fact that at least one of them must indirect * through an unlocked structure to find the synchronizing * lock structure. This is because sleep() * and wakeup() share direct knowledge only of r while diff --git a/port/segment.c b/port/segment.c index fe1cbf4a6f0ffb0ef3188d076a9e0e1d3cba15b2..7c84bbf7f8fef3b1155949900e6145ab9bfc5b39 100644 --- a/port/segment.c +++ b/port/segment.c @@ -424,16 +424,21 @@ ibrk(ulong addr, int seg) return 0; } +/* + * called with s->lk locked + */ void mfreeseg(Segment *s, ulong start, int pages) { int i, j; ulong soff; Page *pg; + Page *list; soff = start-s->base; j = (soff&(PTEMAPMEM-1))/BY2PG; + list = nil; for(i = soff/PTEMAPMEM; i < SEGMAPSIZE; i++) { if(pages <= 0) break; @@ -444,16 +449,24 @@ mfreeseg(Segment *s, ulong start, int pages) } while(j < PTEPERTAB) { pg = s->map[i]->pages[j]; - if(pg) { - putpage(pg); + if(pg) s->map[i]->pages[j] = 0; - } + pg->next = list; + list = pg; if(--pages == 0) - return; + goto out; j++; } j = 0; } +out: + /* wait for others to get fix their tlb's and then free the pages */ + if((s->type&SG_TYPE) == SG_SHARED){ + } + for(pg = list; pg != nil; pg = list){ + list = list->next; + putpage(pg); + } } int