Commits

Peter Szilagyi  committed e7be8ef

Also kill children in omake-server's signal handlers.

  • Participants
  • Parent commits 2147a31
  • Tags 2012-11-13-roll-test

Comments (0)

Files changed (6)

 8a5f29318d039e70170a7cf228f7b263a8ad6b72 2012-11-05-roll-test
 8876e892cc5c48988723357d182bb29efd575a15 2012-11-05-roll-test
 b3c4858857fa594d75a905ece5c676dde00cfbb7 2012-11-13-roll-test
-b3c4858857fa594d75a905ece5c676dde00cfbb7 2012-11-13-roll-test
-ce75de84065ed266e1df5afd2d126667b2cfbba4 2012-11-13-roll-test
 ================================================================================
-2012-11-13 Rolled rev ce75de84065e to test
+2012-11-13 Rolled rev _ to test
 ================================================================================
 
 bug fixes

File ocaml/omake/projects.ml

   Writer.save Files.server_state ~contents:body >>| fun () ->
   Emacs.Async.load_server_state_file ()
 
+let stop_server shutdown_stat =
+  killall () >>= fun () ->
+  update_all () >>= fun () ->
+  Emacs.Async.send_all "(Omake.Connection.close)";
+  Log.printf "Stopping server with %d" shutdown_stat;
+  shutdown shutdown_stat;
+  Deferred.unit

File ocaml/omake/projects.mli

 val update_all : unit -> unit deferred
 val logf : Id.t -> ('a, unit, string, unit) format4 -> 'a
 val pp : unit -> string
+val stop_server : int -> unit deferred

File ocaml/omake/query.ml

       end;
       Deferred.unit
     | Stop_server ->
-      Projects.killall () >>= fun () ->
-      Projects.update_all () >>= fun () ->
-      Emacs.Async.send_all "(Omake.Connection.close)";
-      Log.printf "Stopping server";
-      shutdown 0;
-      Deferred.unit
+      Projects.stop_server 0
     | Show_state -> Writer.writef writer "%s\n" (show_state ());
       Deferred.unit
     | Register_emacs pid ->

File ocaml/omake/top.ml

 	    (* Let do_at_exit remove the lock. *)
 	    Signal.handle [signal] ~f:(fun signal ->
 	      Log.printf "Shutting down on %s" (Signal.to_string signal);
-	      shutdown (Signal.to_system_int signal))));
-        try_with Server.start >>| function
+	      (* This should really be done in at_exit, but then how to wait until it
+		 finishes before exiting?  This way, Projects.stop_server doesn't shut
+		 down until everything's done (esp. killing children). *)
+	      don't_wait_for (Projects.stop_server (Signal.to_system_int signal)))));
+	try_with Server.start >>| function
         | Ok () ->
           Log.printf "Impossible: start_controller returned";
           shutdown 1