M port/devdk.c => port/devdk.c +2 -3
@@ 308,8 308,7 @@ dkalloc(char *name, int ncsc, int lines)
}
/*
- * a new dkmux. find a free dk structure and assign it to this queue.
- * when we get though here dp->s is meaningful and the name is set to "/".
+ * a new dkmux. hold the stream in place so it can never be closed down.
*/
static void
dkmuxopen(Queue *q, Stream *s)
@@ 322,7 321,7 @@ dkmuxopen(Queue *q, Stream *s)
}
/*
- * close down a dkmux
+ * close down a dkmux, this shouldn't happen
*/
static void
dkmuxclose(Queue *q)
M port/devip.c => port/devip.c +2 -0
@@ 663,7 663,9 @@ tcpstclose(Queue *q)
tcb = &s->tcpctl;
/* Not interested in data anymore */
+ qlock(s);
s->readq = 0;
+ qunlock(s);
switch(tcb->state){
case Closed:
M port/tcpif.c => port/tcpif.c +6 -4
@@ 29,9 29,6 @@ state_upcall(Ipconv *s, char oldstate, char newstate)
s->dst = 0;
/* NO break */
case Close_wait: /* Remote closes */
- if(s->readq == 0)
- break;
-
if(s->err) {
len = strlen(s->err);
bp = allocb(len);
@@ 43,7 40,12 @@ state_upcall(Ipconv *s, char oldstate, char newstate)
bp->flags |= S_DELIM;
bp->type = M_HANGUP;
- PUTNEXT(s->readq, bp);
+ qlock(s);
+ if(s->readq == 0)
+ freeb(bp);
+ else
+ PUTNEXT(s->readq, bp);
+ qunlock(s);
break;
}
}
M port/tcpoutput.c => port/tcpoutput.c +2 -0
@@ 239,6 239,7 @@ tcprcvwin(Ipconv *s)
Tcpctl *tcb = &s->tcpctl;
/* Calculate new window */
+ qlock(s);
if(s->readq) {
tcb->rcv.wnd = Streamhi - s->readq->next->len;
if(tcb->rcv.wnd < 0)
@@ 246,6 247,7 @@ tcprcvwin(Ipconv *s)
}
else
tcb->rcv.wnd = Streamhi;
+ qunlock(s);
}
/*