diff --git a/core/json_interface/protocol.ML b/core/json_interface/protocol.ML index b2981223..9a7af899 100644 --- a/core/json_interface/protocol.ML +++ b/core/json_interface/protocol.ML @@ -51,11 +51,11 @@ end fun version _ = Json.String "2.1" fun dispatch systemf rid json = let - val _ = Log.log 2 "(core) dispatch\n" + val _ = Log.log 2 "(core) dispatch" val controller = arg_str json "controller" val module = arg_str json "module" val function = arg_str json "function" - val _ = Log.log 2 ("(core) got dispatch " ^ controller ^ "::" ^ module ^ "::" ^ function ^ "\n") + val _ = Log.log 2 ("(core) got dispatch " ^ controller ^ "::" ^ module ^ "::" ^ function) val json_input = case optarg_json json "input" of SOME x => x | NONE => Json.mk_object [] val json_output = Json.mk_object [ @@ -68,7 +68,7 @@ fun dispatch systemf rid json = let ] handle user_exn msg => json_error rid 0 msg | protocol_exn msg => json_error rid ~1 msg - val _ = Log.log 2 "(core) dispatch worker finished\n" + val _ = Log.log 2 "(core) dispatch worker finished" in json_output end @@ -129,46 +129,46 @@ let | system _ _ = raise user_exn ("Unrecognized system function. (options: help, kill, version)") fun push_output json = ( - Log.log 2 "(core) push_output: waiting for lock\n"; + Log.log 2 "(core) push_output: waiting for lock"; Mutex.lock output_lock; - Log.log 2 "(core) push_output: obtained lock\n"; + Log.log 2 "(core) push_output: obtained lock"; output_buffer := (json :: !output_buffer); ConditionVar.broadcast has_output; Mutex.unlock output_lock; - Log.log 2 "(core) push_output: released lock\n" + Log.log 2 "(core) push_output: released lock" ) fun flush_all buf = fold_rev (fn json => fn () => TextIO.output (outstream, Json.encode json)) buf () fun output_loop () = ( - Log.log 2 "(core) waiting for lock on output loop\n"; + Log.log 2 "(core) waiting for lock on output loop"; Mutex.lock output_lock; - Log.log 2 "(core) obtained lock on output loop\n"; + Log.log 2 "(core) obtained lock on output loop"; if List.null (!output_buffer) then ConditionVar.wait (has_output, output_lock) else (); if List.null (!output_buffer) then () else Log.log 2 "writing output"; flush_all (!output_buffer); output_buffer := []; Mutex.unlock output_lock; - Log.log 2 "(core) released lock on output loop\n"; + Log.log 2 "(core) released lock on output loop"; TextIO.flushOut outstream; output_loop () ) fun input_loop src = let - val _ = Log.log 2 "(core) waiting for request on input loop\n" + val _ = Log.log 2 "(core) waiting for request on input loop" val (json_list, src') = Source.get src - val _ = Log.log 2 "(core) got request\n" + val _ = Log.log 2 "(core) got request" val json = case json_list of [x] => x | _ => raise protocol_exn "Expected: exactly one JSON object" val rid = arg_int json "request_id" - val _ = Log.log 2 "(core) preparing to update job table\n" + val _ = Log.log 2 "(core) preparing to update job table" val _ = Synchronized.change job_table (fn tab => ( - Log.log 2 "(core) updating job table\n"; + Log.log 2 "(core) updating job table"; if IntName.NSet.contains (JobTable.get_dom_set tab) rid then (push_output (json_error rid 0 "Duplicate request ID"); tab) else let - val _ = Log.log 2 "(core) forking new worker\n" - val worker = Future.fork (fn () => (Log.log 2 "(core) worker forked\n"; dispatch system rid json)) + val _ = Log.log 2 "(core) forking new worker" + val worker = Future.fork (fn () => (Log.log 2 "(core) worker forked"; dispatch system rid json)) in Thread.fork (fn () => ( let val json = PolyML.exception_trace (fn () => ( @@ -185,7 +185,7 @@ let in input_loop src' end in ( - Log.log 2 "(core) forking output loop\n"; Thread.fork (output_loop,[]); + Log.log 2 "(core) forking output loop"; Thread.fork (output_loop,[]); input_loop (Json.json_source instream) ) end diff --git a/core/run_protocol.ML b/core/run_protocol.ML index 36b80df3..42b2a61f 100644 --- a/core/run_protocol.ML +++ b/core/run_protocol.ML @@ -1,6 +1,8 @@ PolyML.SaveState.loadState "heaps/quanto.heap"; PolyML.Compiler.printDepth:=100; +(* Futures may hang unless we allow at least 4 workers *) +if (!Multithreading.max_threads <= 4) then Multithreading.max_threads := 4 else (); fun run_protocol port () = let diff --git a/scala/dist/windows-dist/QuantoDerive.aip b/scala/dist/windows-dist/QuantoDerive.aip index a85cedb7..8c8630e1 100644 --- a/scala/dist/windows-dist/QuantoDerive.aip +++ b/scala/dist/windows-dist/QuantoDerive.aip @@ -1,5 +1,5 @@ - + @@ -7,10 +7,10 @@ - + - + @@ -121,7 +121,7 @@ - + diff --git a/scala/src/main/scala/quanto/util/SignallingStreamRedirector.scala b/scala/src/main/scala/quanto/util/SignallingStreamRedirector.scala index 4938f069..61fbc8de 100644 --- a/scala/src/main/scala/quanto/util/SignallingStreamRedirector.scala +++ b/scala/src/main/scala/quanto/util/SignallingStreamRedirector.scala @@ -29,7 +29,7 @@ case class StreamMessage(parts: MessagePart*) { } def writeTo(out: OutputStream) { - writeTo(new OutputStreamWriter(out)) + writeTo(new OutputStreamWriter(out, "ISO-8859-1")) } def stripCodes = parts.filter{ case _: CodePart => false ; case _ => true }