Browse Source

acme/bin/source/win: increase EVENTSIZE to 16 KB (thanks Geoff Collyer)

David du Colombier 2 years ago
parent
commit
e7fd4cc737
3 changed files with 13 additions and 7 deletions
  1. 1 1
      acme/bin/source/win/dat.h
  2. 11 5
      acme/bin/source/win/fs.c
  3. 1 1
      sys/src/cmd/acme/dat.h

+ 1 - 1
acme/bin/source/win/dat.h

@@ -9,7 +9,7 @@ enum
 	NPIPEDATA	= 8000,
 	NPIPE		= NPIPEDATA+32,
 	/* EVENTSIZE is really 256 in acme, but we use events internally and want bigger buffers */
-	EVENTSIZE	= 8192,
+	EVENTSIZE	= 16*1024,
 	NEVENT		= 5,
 };
 

+ 11 - 5
acme/bin/source/win/fs.c

@@ -44,13 +44,13 @@ fsflush(Req *r)
 static void
 fswrite(Req *r)
 {
-	static Event *e[4];
+	static Event *e[4];	/* ours, not the one from event.h */
+	static int n, partial;
 	Event *ep;
 	int i, j, ei, nb, wid, pid;
 	Rune rune;
 	char *s;
 	char tmp[UTFmax], *t;
-	static int n, partial;
 
 	if(r->fid->file == devnew){
 		if(r->fid->aux){
@@ -84,8 +84,14 @@ fswrite(Req *r)
 
 	ep = e[n];
 	n = (n+1)%nelem(e);
-	assert(r->ifcall.count <= 8192);	/* is this guaranteed by lib9p? */
+	/*
+	 * lib9p ensures that r->ifcall.count is <= srv->msize - IOHDRSZ,
+	 * where srv == &fs.
+	 */
+	assert((int)r->ifcall.count >= 0);
 	nb = r->ifcall.count;
+	if (partial + nb >= sizeof ep->b)
+		sysfatal("EVENTSIZE < MAXRPC; increase EVENTSIZE & recompile");
 	memmove(ep->b+partial, r->ifcall.data, nb);
 	nb += partial;
 	ep->b[nb] = '\0';
@@ -97,12 +103,12 @@ fswrite(Req *r)
 		nb = j;
 		t[j] = '\0';
 	}
-	ei = nb>8192? 8192 : nb;
+	ei = nb>EVENTSIZE? EVENTSIZE: nb;
 	/* process bytes into runes, transferring terminal partial runes into next buffer */
 	for(i=j=0; i<ei && fullrune(ep->b+i, ei-i); i+=wid,j++)
 		wid = chartorune(&rune, ep->b+i);
 	memmove(tmp, ep->b+i, nb-i);
-	partial = nb-i;
+//	partial = nb-i;			/* redundant */
 	ep->nb = i;
 	ep->nr = j;
 	ep->b[i] = '\0';

+ 1 - 1
sys/src/cmd/acme/dat.h

@@ -27,7 +27,7 @@ enum
 enum
 {
 	Blockincr =	256,
-	Maxblock = 	8*1024,
+	Maxblock = 	16*1024,
 	NRange =		10,
 	Infinity = 		0x7FFFFFFF,	/* huge value for regexp address */
 };