Fix bug that was occurring when two regen's were run in a row
[hcoop/domtool2.git] / src / main.sml
index 0be3112..aca57ed 100644 (file)
@@ -1,5 +1,5 @@
 (* HCoop Domtool (http://hcoop.sourceforge.net/)
- * Copyright (c) 2006, Adam Chlipala
+ * Copyright (c) 2006-2007, Adam Chlipala
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -787,7 +787,13 @@ fun requestFirewall {node, uname} =
 
 fun regenerate context =
     let
+       val _ = ErrorMsg.reset ()
+
        val b = basis ()
+       val _ = if Env.lookupType b "string" then
+                   print "Still got it\n"
+               else
+                   print "Don't got it\n"
        val () = Tycheck.disallowExterns ()
 
        val () = Domain.resetGlobal ()
@@ -847,6 +853,7 @@ fun regenerate context =
                handle IO.Io _ => ()
                     | OS.SysErr (s, _) => print ("System error processing user " ^ user ^ ": " ^ s ^ "\n")
                     | ErrorMsg.Error => print ("User " ^ user ^ " had a compilation error.\n")
+                    | _ => print "Unknown exception during regeneration!\n"
     in
        app contactNode Config.nodeIps;
        Env.pre ();
@@ -1252,6 +1259,18 @@ fun service () =
                            OpenSSL.close bio
                            handle OpenSSL.OpenSSL _ => ();
                            loop ())
+                        | IO.Io {name, function, cause} =>
+                          (print ("IO error: " ^ function ^ " for " ^ name ^ "\n");
+                           app (fn x => print (x ^ "\n")) (SMLofNJ.exnHistory cause);
+                           OpenSSL.close bio
+                           handle OpenSSL.OpenSSL _ => ();
+                           loop ())
+                        | e =>
+                          (print "Unknown exception in main loop!\n";
+                           app (fn x => print (x ^ "\n")) (SMLofNJ.exnHistory e);
+                           OpenSSL.close bio
+                           handle OpenSSL.OpenSSL _ => ();
+                           loop ())
     in
        print ("Domtool dispatcher starting up at " ^ now () ^ "\n");
        print "Listening for connections....\n";
@@ -1318,8 +1337,9 @@ fun slave () =
                            OpenSSL.close bio
                                          handle OpenSSL.OpenSSL _ => ();
                            loop ())
-                        | OS.SysErr (s, _) =>
-                          (print ("System error: "^ s ^ "\n");
+                        | e as OS.SysErr (s, _) =>
+                          (app (fn s => print (s ^ "\n")) (SMLofNJ.exnHistory e);
+                           print ("System error: "^ s ^ "\n");
                            OpenSSL.close bio
                            handle OpenSSL.OpenSSL _ => ();
                            loop ())