Skip to content

Commit

Permalink
Fix tracing log.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Jul 5, 2023
1 parent 18de991 commit 5808275
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.4.6 (unreleased)
=====
* Fix tracing log.

0.4.5 (2023-06-27)
=====
* Add optional log colorization function.
Expand Down
49 changes: 23 additions & 26 deletions src/dtools_impl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -420,38 +420,35 @@ module Init = struct
stop.depends <- a :: stop.depends;
a

let exec a =
let rec exec a =
let log =
if conf_trace#get then fun s ->
let id = Thread.id (Thread.self ()) in
Printf.printf "init(%i):%-35s@%s\n%!" id a.name s
else fun _ -> ()
in
let rec exec a =
log "called";
Mutex.lock a.mutex;
try
if not a.launched then begin
a.launched <- true;
log "start";
log "start-depends";
List.iter exec a.depends;
log "stop-depends";
log "start-atom";
a.f ();
log "stop-atom";
log "start-triggers";
List.iter exec a.triggers;
log "stop-triggers";
log "stop"
end;
Mutex.unlock a.mutex;
log "return"
with e ->
Mutex.unlock a.mutex;
raise e
in
exec a
log "called";
Mutex.lock a.mutex;
try
if not a.launched then begin
a.launched <- true;
log "start";
log "start-depends";
List.iter exec a.depends;
log "stop-depends";
log "start-atom";
a.f ();
log "stop-atom";
log "start-triggers";
List.iter exec a.triggers;
log "stop-triggers";
log "stop"
end;
Mutex.unlock a.mutex;
log "return"
with e ->
Mutex.unlock a.mutex;
raise e

let rec wait_signal () =
try ignore (Thread.wait_signal [Sys.sigterm; Sys.sigint]) with
Expand Down

0 comments on commit 5808275

Please sign in to comment.