Skip to content

Commit

Permalink
Trace fill_and_blit only if block is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
astrada committed Jan 6, 2017
1 parent fd2fe96 commit c593433
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/buffering.ml
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,17 @@ struct
let end_pos =
min resource_size (Int64.add offset (Int64.of_int dest_arr_size)) in
let end_block_index = get_block_index end_pos buffers in
Utils.log_with_header
"Fill starting block (remote id=%s, start_block_index=%d, offset=%Ld, \
dest_arr_size=%s)\n%!"
remote_id start_block_index offset
(Option.map_default
(fun _ -> string_of_int dest_arr_size)
"N/A"
dest_arr);
if start_block_index < 0 || offset < 0L then begin
Utils.log_with_header
"Invalid starting block (remote id=%s, start_block_index=%d, \
offset=%Ld, resource_size=%Ld, dest_arr_size=%s)\n%!"
remote_id start_block_index offset resource_size
(Option.map_default
(fun _ -> string_of_int dest_arr_size)
"N/A"
dest_arr);
invalid_arg "fill_and_blit"
end;
fill_and_blit start_block_index offset dest_arr >>= fun () ->
if end_block_index <> start_block_index then begin
let src_offset = get_block_start_pos end_block_index buffers in
Expand All @@ -153,10 +156,13 @@ struct
Option.map
(fun arr -> Bigarray.Array1.sub arr dest_offset dest_len)
dest_arr in
Utils.log_with_header
"Fill ending block (remote id=%s, end_block_index=%d, \
src_offset=%Ld, dest_len=%d)\n%!"
remote_id end_block_index src_offset dest_len;
if end_block_index < 0 || src_offset < 0L then begin
Utils.log_with_header
"Invalid ending block (remote id=%s, end_block_index=%d, \
src_offset=%Ld, dest_len=%d, resource_size=%Ld)\n%!"
remote_id end_block_index src_offset dest_len resource_size;
invalid_arg "fill_and_blit"
end;
fill_and_blit end_block_index src_offset dest_arr
end else SessionM.return ()
end else SessionM.return ()
Expand Down

0 comments on commit c593433

Please sign in to comment.