changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > ventivac / changeset: minor changes. do not kill processes, just send nil over channel. do not pctl pgrp.

changeset 104: bd9330e95ebb
parent 103: c6c061169cb7
child 105: b2d15be09468
author: Mechiel Lukkien <mechiel@ueber.net>
date: Wed, 15 Aug 2007 18:02:32 +0200
files: appl/cmd/vacfs.b
description: minor changes. do not kill processes, just send nil over channel. do not pctl pgrp.
     1.1--- a/appl/cmd/vacfs.b	Wed Aug 15 16:02:22 2007 +0200
     1.2+++ b/appl/cmd/vacfs.b	Wed Aug 15 18:02:32 2007 +0200
     1.3@@ -32,7 +32,7 @@
     1.4 dflag := pflag := 0;
     1.5 session: ref Session;
     1.6 
     1.7-ss: ref Styxserver;
     1.8+srv: ref Styxserver;
     1.9 
    1.10 Elem: adt {
    1.11 	qid:	int;
    1.12@@ -227,7 +227,6 @@
    1.13 	styxservers = load Styxservers Styxservers->PATH;
    1.14 	vac = load Vac Vac->PATH;
    1.15 
    1.16-	sys->pctl(sys->NEWPGRP, nil);
    1.17 	venti->init();
    1.18 	vac->init();
    1.19 	styx->init();
    1.20@@ -290,23 +289,25 @@
    1.21 	spawn navigator(navchan);
    1.22 
    1.23 	msgc: chan of ref Tmsg;
    1.24-	(msgc, ss) = Styxserver.new(sys->fildes(0), nav, big rqid);
    1.25+	(msgc, srv) = Styxserver.new(sys->fildes(0), nav, big rqid);
    1.26 
    1.27-	for(;;) {
    1.28-		pick m := <- msgc {
    1.29+serve:
    1.30+	while((mm := <-msgc) != nil)
    1.31+		pick m := mm {
    1.32 		Readerror =>
    1.33-			say("read error: "+m.error);
    1.34+			fprint(fildes(2), "styx read: %s\n", m.error);
    1.35+			break serve;
    1.36 
    1.37 		Read =>
    1.38 			say(sprint("have read, offset=%ubd count=%d", m.offset, m.count));
    1.39-			(c, err) := ss.canread(m);
    1.40+			(c, err) := srv.canread(m);
    1.41 			if(c == nil){
    1.42-				ss.reply(ref Rmsg.Error(m.tag, err));
    1.43-				break;
    1.44+				srv.reply(ref Rmsg.Error(m.tag, err));
    1.45+				continue;
    1.46 			}
    1.47 			if(c.qtype & Sys->QTDIR){
    1.48-				ss.default(m);
    1.49-				break;
    1.50+				srv.default(m);
    1.51+				continue;
    1.52 			}
    1.53 
    1.54 			ef := getfile(int c.path);
    1.55@@ -314,22 +315,22 @@
    1.56 			a := array[n] of byte;
    1.57 			have := ef.vf.pread(a, n, m.offset);
    1.58 			if(have < 0) {
    1.59-				ss.reply(ref Rmsg.Error(m.tag, sprint("%r")));
    1.60-				break;
    1.61+				srv.reply(ref Rmsg.Error(m.tag, sprint("%r")));
    1.62+				continue;
    1.63 			}
    1.64-			ss.reply(ref Rmsg.Read(m.tag, a[:have]));
    1.65+			srv.reply(ref Rmsg.Read(m.tag, a[:have]));
    1.66 
    1.67 		Open =>
    1.68 			(c, mode, f, err) := canopen(m);
    1.69 			if(c == nil){
    1.70-				ss.reply(ref Rmsg.Error(m.tag, err));
    1.71-				break;
    1.72+				srv.reply(ref Rmsg.Error(m.tag, err));
    1.73+				continue;
    1.74 			}
    1.75 			c.open(mode, f.qid);
    1.76-			ss.reply(ref Rmsg.Open(m.tag, f.qid, ss.iounit()));
    1.77+			srv.reply(ref Rmsg.Open(m.tag, f.qid, srv.iounit()));
    1.78 
    1.79 		Clunk =>
    1.80-			f := ss.getfid(m.fid);
    1.81+			f := srv.getfid(m.fid);
    1.82 			if(f != nil) {
    1.83 				pick e := get(int f.path) {
    1.84 				Dir =>
    1.85@@ -340,22 +341,23 @@
    1.86 						del(e);
    1.87 				}
    1.88 			}
    1.89-			ss.default(m);
    1.90+			srv.default(m);
    1.91 
    1.92 		* =>
    1.93-			ss.default(m);
    1.94+			srv.default(m);
    1.95 		}
    1.96-	}
    1.97+	navchan <-= nil;
    1.98 }
    1.99 
   1.100+# from appl/lib/styxservers.b
   1.101 canopen(m: ref Tmsg.Open): (ref Fid, int, ref Sys->Dir, string)
   1.102 {
   1.103-	c := ss.getfid(m.fid);
   1.104+	c := srv.getfid(m.fid);
   1.105 	if(c == nil)
   1.106 		return (nil, 0, nil, Styxservers->Ebadfid);
   1.107 	if(c.isopen)
   1.108 		return (nil, 0, nil, Styxservers->Eopen);
   1.109-	(f, err) := ss.t.stat(c.path);
   1.110+	(f, err) := srv.t.stat(c.path);
   1.111 	if(f == nil)
   1.112 		return (nil, 0, nil, err);
   1.113 	mode := styxservers->openmode(m.mode);
   1.114@@ -372,9 +374,7 @@
   1.115 
   1.116 navigator(c: chan of ref Navop)
   1.117 {
   1.118-loop:
   1.119-	for(;;) {
   1.120-		navop := <- c;
   1.121+	while((navop := <-c) != nil)
   1.122 		pick n := navop {
   1.123 		Stat =>
   1.124 			n.reply <-= (get(int n.path).stat(), nil);
   1.125@@ -384,7 +384,7 @@
   1.126 			(ne, err) := walk(ed, n.name);
   1.127 			if(err != nil) {
   1.128 				n.reply <-= (nil, err);
   1.129-				break;
   1.130+				continue;
   1.131 			}
   1.132 			ed.nused--;
   1.133 			ne.nused++;
   1.134@@ -394,7 +394,7 @@
   1.135 			if(dflag) say(sprint("have readdir path=%bd offset=%d count=%d", n.path, n.offset, n.count));
   1.136 			if(n.path == big 0) {
   1.137 				n.reply <-= (nil, nil);
   1.138-				break;
   1.139+				continue;
   1.140 			}
   1.141 			ed := getdir(int n.path);
   1.142 			if(n.offset == 0) {
   1.143@@ -408,7 +408,7 @@
   1.144 				if(ok < 0) {
   1.145 					say(sprint("readdir error: %r"));
   1.146 					n.reply <-= (nil, sprint("reading directory: %r"));
   1.147-					continue loop;
   1.148+					continue;
   1.149 				}
   1.150 				if(de != nil) {
   1.151 					cqid := childget(ed.qid, de.qid);
   1.152@@ -428,12 +428,10 @@
   1.153 				n.reply <-= (d, nil);
   1.154 			n.reply <-= (nil, nil);
   1.155 		}
   1.156-	}
   1.157 }
   1.158 
   1.159 error(s: string)
   1.160 {
   1.161-	killgrp();
   1.162 	fprint(fildes(2), "%s\n", s);
   1.163 	raise "fail:"+s;
   1.164 }
   1.165@@ -443,10 +441,3 @@
   1.166 	if(dflag)
   1.167 		fprint(fildes(2), "%s\n", s);
   1.168 }
   1.169-
   1.170-killgrp()
   1.171-{
   1.172-	fd := sys->open("/prog/"+string sys->pctl(0, nil)+"/ctl", sys->OWRITE);
   1.173-	if(fd != nil)
   1.174-		sys->fprint(fd, "killgrp\n");
   1.175-}