From 517e4604a170bd835c325607f1500bcefec5a276 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 6 Mar 2001 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2001-03-06 --- ip/devip.c | 4 ++-- ip/esp.c | 2 +- ip/gre.c | 4 +--- ip/icmp.c | 3 +-- ip/il.c | 5 +---- ip/ip.h | 2 +- ip/ipifc.c | 2 +- ip/ipmux.c | 2 +- ip/rudp.c | 2 +- ip/tcp.c | 31 +++++++++++++++---------------- ip/udp.c | 2 +- port/portfns.h | 2 +- port/qio.c | 4 +++- 13 files changed, 30 insertions(+), 35 deletions(-) diff --git a/ip/devip.c b/ip/devip.c index 747d9eeb65efeea40b9064b47e90be9cfba31679..38bfb2120909dc9c140c79fc35c6d5e33ec0dbef 100644 --- a/ip/devip.c +++ b/ip/devip.c @@ -988,7 +988,7 @@ ipwrite(Chan* ch, void *v, long n, vlong off) error(Eperm); qwrite(c->wq, a, n); - x->kick(c, n); + x->kick(c); break; case Qarp: return arpwrite(f, a, n); @@ -1081,7 +1081,7 @@ ipbwrite(Chan* ch, Block* bp, ulong offset) bp = concatblock(bp); n = BLEN(bp); qbwrite(c->wq, bp); - x->kick(c, n); + x->kick(c); return n; default: return devbwrite(ch, bp, offset); diff --git a/ip/esp.c b/ip/esp.c index 4ccbef72e546d319f8258d0cc8aa93a721c16ece..44aa8f28066ef1e6a48453aee9bd53184a7e96f8 100644 --- a/ip/esp.c +++ b/ip/esp.c @@ -220,7 +220,7 @@ espclose(Conv *c) } void -espkick(Conv *c, int) +espkick(Conv *c) { Esphdr *eh; Esptail *et; diff --git a/ip/gre.c b/ip/gre.c index 54e38997a9a0dc82b4767cdcf08aae85d073458b..a2d397ac8f03e1c7b999aaa7d3ee4da0de8f1ea3 100644 --- a/ip/gre.c +++ b/ip/gre.c @@ -119,14 +119,12 @@ greclose(Conv *c) int drop; static void -grekick(Conv *c, int l) +grekick(Conv *c) { GREhdr *ghp; Block *bp; uchar laddr[IPaddrlen], raddr[IPaddrlen]; - USED(l); - bp = qget(c->wq); if(bp == nil) return; diff --git a/ip/icmp.c b/ip/icmp.c index 9db10da49fdba76f62863267738d9a173b92139f..f74a3fa72ef88c57b0453059adbb080a7d8a2447 100644 --- a/ip/icmp.c +++ b/ip/icmp.c @@ -148,13 +148,12 @@ icmpclose(Conv *c) } static void -icmpkick(Conv *c, int l) +icmpkick(Conv *c) { Icmp *p; Block *bp; Icmppriv *ipriv; - USED(l); bp = qget(c->wq); if(bp == nil) return; diff --git a/ip/il.c b/ip/il.c index 5d36a29bcab9674d47d94cc6b58915b084ece5a0..027cddc07d730db11776da74db621c9096e84ac2 100644 --- a/ip/il.c +++ b/ip/il.c @@ -335,7 +335,7 @@ ilclose(Conv *c) } void -ilkick(Conv *c, int l) +ilkick(Conv *c) { Ilhdr *ih; Ilcb *ic; @@ -345,9 +345,6 @@ ilkick(Conv *c, int l) Fs *f; Ilpriv *priv; - - USED(l); - f = c->p->f; priv = c->p->priv; ic = (Ilcb*)c->ptcl; diff --git a/ip/ip.h b/ip/ip.h index 23ffb8bdcd4cbe02e60f014463d77fb7dbb8b1c1..5c2a8f0df6b2445b5fd287d9c6465a0a2011e88e 100644 --- a/ip/ip.h +++ b/ip/ip.h @@ -235,7 +235,7 @@ struct Proto int x; /* protocol index */ int ipproto; /* ip protocol type */ - void (*kick)(Conv*, int); + void (*kick)(Conv*); char* (*connect)(Conv*, char**, int); char* (*announce)(Conv*, char**, int); char* (*bind)(Conv*, char**, int); diff --git a/ip/ipifc.c b/ip/ipifc.c index 54e18eb001bc3177c9e0ff836e2f433185f83a0e..09a0e0784ee57199a884996016ab943066ec20a6 100644 --- a/ip/ipifc.c +++ b/ip/ipifc.c @@ -257,7 +257,7 @@ ipifcinuse(Conv *c) * called when a process writes to an interface's 'data' */ static void -ipifckick(Conv *c, int) +ipifckick(Conv *c) { Block *bp; Ipifc *ifc; diff --git a/ip/ipmux.c b/ip/ipmux.c index f30a9a07d75f9f8e70ea1531c09eefc8612562da..ddea33d9ef9985c7d3f12e6b3f0a012f5110a3e8 100644 --- a/ip/ipmux.c +++ b/ip/ipmux.c @@ -626,7 +626,7 @@ ipmuxclose(Conv *c) * the stack */ static void -ipmuxkick(Conv *c, int) +ipmuxkick(Conv *c) { Block *bp; Iphdr *ih; diff --git a/ip/rudp.c b/ip/rudp.c index 75fe75319c24b8f2d8476cd64755dc34c3342b20..463e766d6c1126298d4d7eaef104cbc9f99e1554 100644 --- a/ip/rudp.c +++ b/ip/rudp.c @@ -333,7 +333,7 @@ flow(void *v) } void -rudpkick(Conv *c, int) +rudpkick(Conv *c) { Udphdr *uh; ushort rport; diff --git a/ip/tcp.c b/ip/tcp.c index 9f8b8964595008e7f506b3220b023bd6dd5dc67f..735a5f7f8a368670e91b65e539cd037acc3194d4 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -176,7 +176,6 @@ struct Tcpctl uchar backoff; /* Exponential backoff counter */ int backedoff; /* ms we've backed off for rexmits */ uchar flags; /* State flags */ - ulong sndcnt; /* Amount of data in send queue */ Reseq *reseq; /* Resequencing queue */ Timer timer; /* Activity timer */ Timer acktimer; /* Acknowledge timer */ @@ -189,6 +188,7 @@ struct Tcpctl uint sndsyntime; /* time syn sent */ ulong time; /* time Finwait2 or Syn_received was sent */ int nochecksum; /* non-zero means don't send checksums */ + int flgcnt; /* 1 when we're waiting for a SYN/FIN ACK */ Tcphdr protohdr; /* prototype header */ }; @@ -393,13 +393,13 @@ tcpclose(Conv *c) break; case Syn_received: case Established: - tcb->sndcnt++; + tcb->flgcnt++; tcb->snd.nxt++; tcpsetstate(c, Finwait1); tcpoutput(c); break; case Close_wait: - tcb->sndcnt++; + tcb->flgcnt++; tcb->snd.nxt++; tcpsetstate(c, Last_ack); tcpoutput(c); @@ -408,7 +408,7 @@ tcpclose(Conv *c) } void -tcpkick(Conv *s, int len) +tcpkick(Conv *s) { Tcpctl *tcb; @@ -433,7 +433,6 @@ tcpkick(Conv *s, int len) /* * Push data */ - tcb->sndcnt += len; tcprcvwin(s); tcpoutput(s); break; @@ -888,7 +887,7 @@ tcpsndsyn(Tcpctl *tcb) tcb->snd.una = tcb->iss; tcb->snd.ptr = tcb->rttseq; tcb->snd.nxt = tcb->rttseq; - tcb->sndcnt++; + tcb->flgcnt++; tcb->flags |= FORCE; tcb->sndsyntime = msec; } @@ -1150,7 +1149,7 @@ update(Conv *s, Tcp *seg) if((tcb->flags & SYNACK) == 0) { tcb->flags |= SYNACK; acked--; - tcb->sndcnt--; + tcb->flgcnt--; goto done; } @@ -1200,9 +1199,9 @@ update(Conv *s, Tcp *seg) } done: - qdiscard(s->wq, acked); + if(qdiscard(s->wq, acked) < acked) + tcb->flgcnt--; - tcb->sndcnt -= acked; tcb->snd.una = seg->ack; if(seq_gt(seg->ack, tcb->snd.urg)) tcb->snd.urg = seg->ack; @@ -1380,7 +1379,7 @@ reset: if(tcptrim(tcb, &seg, &bp, &length) == -1) { netlog(f, Logtcp, "tcp len < 0, %lux\n", seg.seq); update(s, &seg); - if(tcb->sndcnt == 0 && tcb->state == Closing) { + if(qlen(s->wq)+tcb->flgcnt == 0 && tcb->state == Closing) { tcphalt(tpriv, &tcb->rtt_timer); tcphalt(tpriv, &tcb->acktimer); tcphalt(tpriv, &tcb->katimer); @@ -1445,7 +1444,7 @@ reset: break; case Finwait1: update(s, &seg); - if(tcb->sndcnt == 0){ + if(qlen(s->wq)+tcb->flgcnt == 0){ tcphalt(tpriv, &tcb->rtt_timer); tcphalt(tpriv, &tcb->acktimer); tcpsetkacounter(tcb); @@ -1460,7 +1459,7 @@ reset: break; case Closing: update(s, &seg); - if(tcb->sndcnt == 0) { + if(qlen(s->wq)+tcb->flgcnt == 0) { tcphalt(tpriv, &tcb->rtt_timer); tcphalt(tpriv, &tcb->acktimer); tcphalt(tpriv, &tcb->katimer); @@ -1471,7 +1470,7 @@ reset: break; case Last_ack: update(s, &seg); - if(tcb->sndcnt == 0) { + if(qlen(s->wq)+tcb->flgcnt == 0) { localclose(s, nil); goto raise; } @@ -1560,7 +1559,7 @@ reset: break; case Finwait1: tcb->rcv.nxt++; - if(tcb->sndcnt == 0) { + if(qlen(s->wq)+tcb->flgcnt == 0) { tcphalt(tpriv, &tcb->rtt_timer); tcphalt(tpriv, &tcb->acktimer); tcphalt(tpriv, &tcb->katimer); @@ -1616,7 +1615,7 @@ raise: qunlock(s); poperror(); freeblist(bp); - tcpkick(s, 0); + tcpkick(s); } /* @@ -1656,7 +1655,7 @@ tcpoutput(Conv *s) tcb->flags |= FORCE; } - sndcnt = tcb->sndcnt; + sndcnt = qlen(s->wq)+tcb->flgcnt; sent = tcb->snd.ptr - tcb->snd.una; /* Don't send anything else until our SYN has been acked */ diff --git a/ip/udp.c b/ip/udp.c index 80b849599dd24466460dcb12fd19d021f5f7a34f..c4fcc5a0cc701b1be7498ad951990180e36e650f 100644 --- a/ip/udp.c +++ b/ip/udp.c @@ -147,7 +147,7 @@ udpclose(Conv *c) } void -udpkick(Conv *c, int) +udpkick(Conv *c) { Udphdr *uh; ushort rport; diff --git a/port/portfns.h b/port/portfns.h index 9adb028b9368938bc5c0a9fb7f306397e6410e0b..d74f7175dc776c6d68723708bd7da124b90e5421 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -233,7 +233,7 @@ int qcanread(Queue*); void qclose(Queue*); int qconsume(Queue*, void*, int); Block* qcopy(Queue*, int, ulong); -void qdiscard(Queue*, int); +int qdiscard(Queue*, int); void qflush(Queue*); void qfree(Queue*); int qfull(Queue*); diff --git a/port/qio.c b/port/qio.c index ac392c1c3e45289987cc06ad827146a926a6a0db..d6ea7eb4b39b4b33acfadf0310f06e67e65db436 100644 --- a/port/qio.c +++ b/port/qio.c @@ -406,7 +406,7 @@ qget(Queue *q) /* * throw away the next 'len' bytes in the queue */ -void +int qdiscard(Queue *q, int len) { Block *b; @@ -443,6 +443,8 @@ qdiscard(Queue *q, int len) if(dowakeup) wakeup(&q->wr); + + return sofar; } /*