code: drawterm

Download patch

ref: 64c6eaaaef193ef730f16c6217a6d3e6b8fdb719
parent: e61ca3be6f93135afc575df89d146e946e2b6ec4
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Feb 3 20:35:35 EST 2017

aan: use unsigned message counters

--- a/aan.c
+++ b/aan.c
@@ -35,8 +35,8 @@
 	int	writer;
 	int	syncer;
 
-	long	inmsg;
-	long	outmsg;
+	ulong	inmsg;
+	ulong	outmsg;
 
 	Buf	*unackedhead;
 	Buf	**unackedtail;
@@ -77,7 +77,7 @@
 	Client *c = (Client*)arg;
 	Buf *b;
 	int n;
-	long m;
+	ulong m;
 
 	for(;;){
 		b = malloc(sizeof(Buf));
@@ -138,7 +138,7 @@
 aanreader(void *arg)
 {
 	Client *c = (Client*)arg;
-	long a, m, lastacked = 0;
+	ulong a, m, lastacked = 0;
 	Buf *b, *x;
 	int n;
 
@@ -151,7 +151,7 @@
 		m = GBIT32(b->hdr.msg);
 		n = GBIT32(b->hdr.nb);
 		if(n == 0){
-			if(m < 0)
+			if(m == (ulong)-1)
 				continue;
 			goto Closed;
 		} else if(n < 0 || n > Bufsize)
@@ -159,11 +159,11 @@
 
 		if(readn(c->netfd, b->buf, n) != n)
 			break;
-		if(m < c->inmsg)
+		if(m != c->inmsg)
 			continue;
 		c->inmsg++;
 
-		if(lastacked != a){
+		if((long)(a - lastacked) > 0){
 			qlock(&c->lk);
 			while((x = c->unackedhead) != nil){
 				assert(GBIT32(x->hdr.msg) == lastacked);