Commits

Mechiel Lukkien committed 243c77b Draft

better handling of handshake.

we checked for venti-02-. 02 is the version. but actually the
version sent is a list of colon-separated supported versions. p9p's
vac/venti tools send venti-04:02-. we can now talk to such clients
again.

while here, it seems the problem on openbsd has gone away, so remove
warning in manual page.

  • Participants
  • Parent commits ee6335d

Comments (0)

Files changed (2)

 Starting up is slow since the entire table has to be read in memory.
 .Pp
 Calc.py should be explained better.  Some important things:  start-end ranges can be specified as numbers with a prefix such as k, m, g, etc.  Multiple ranges can be specified, each separated by a comma.
-.Pp
-Memventi first binds to addresses, then initializes (involving a fork) and only then starts accepting connections.  On OpenBSD, this does not work:  new connections are not "seen" by the accept.  The solution is to first initialize and then bind and accept.
 			errxsyslog(1, "init hash table lock");
 }
 
+static int
+compatible(char *s)
+{
+	char *ee, *e;
+
+	if(strlen(s) < 6 || strncmp(s, "venti-", 6) != 0)
+		return 0;
+	s += 6;
+	ee = strchr(s, '-');
+	if(ee == nil)
+		return 0;
+	while(s < ee) {
+		e = strchr(s+1, ':');
+		if(e == nil)
+			e = ee;
+		if(e-s == 2 && strncmp(s, "02", 2) == 0)
+			return 1;
+		s = e+1;
+	}
+	return 0;
+}
 
 static void *
 connproc(void *p)
 	}
 
 	l = fgets(buf, sizeof buf, f);
-	if(l == nil || strncmp(l, "venti-02", 8) != 0) {
+	if(l == nil || !compatible(l)) {
 		debug(LOG_DEBUG, "error reading protocol handshake or wrong protocol version: %s",
 			ferror(f) ? strerror(errno) : "eof");
 		goto done;