chiark / gitweb /
rhodes: Don't try to kill ourselves when zapping redundant workers.
[rhodes] / rhodes
diff --git a/rhodes b/rhodes
index 092e97a5774f975746368b6b11a6f8e3565ad768..b9d97fa602241fccedce9748f371d7f1dd5a5619 100755 (executable)
--- a/rhodes
+++ b/rhodes
@@ -286,7 +286,7 @@ def maybe_cleanup_worker(dir, db, pid):
 
 def maybe_kill_worker(dir, pid):
   f = OS.path.join(dir, 'lk.%d' % pid)
-  try: fd = OS.open(f, OS.O_RDONLY)
+  try: fd = OS.open(f, OS.O_RDWR)
   except OSError, err:
     if err.errno != E.ENOENT: raise ExpectedError, 'open lockfile: %s' % err
     return
@@ -466,7 +466,8 @@ def step(dir, cmd, *args):
       ## we lose a bunch of work. :-(
       c.execute("""SELECT pid FROM workers WHERE p = ? AND k = ?""",
                 (str(p), k))
-      for pid, in c: maybe_kill_worker(dir, pid)
+      for pid, in c:
+        if pid != mypid: maybe_kill_worker(dir, pid)
       c.execute("""DELETE FROM workers WHERE p = ? AND k = ?""",
                 (str(p), k - 1))
       c.execute("""DELETE FROM points WHERE p = ? AND k = ?""",
@@ -490,7 +491,8 @@ def step(dir, cmd, *args):
           p, n = C.MP(pstr), C.MP(nstr)
           qq.append(p**e)
           nn.append(n)
-        n = C.MPCRT(qq).solve(nn)
+        if len(qq) == 1: n = nn[0]
+        else: n = C.MPCRT(qq).solve(nn)
 
         ## One last check that this is the right answer.
         xx = G.pow(g, n)