File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2452,6 +2452,28 @@ let metadata_handler (req : Request.t) s _ =
24522452 debug " Got XML" ;
24532453 (* Skip trailing two zero blocks *)
24542454 Tar_helpers. skip s (Tar.Header. length * 2 ) ;
2455+ (* Drain any remaining body bytes (e.g. tar RECORDSIZE padding)
2456+ to prevent EPIPE on the client. See CA-426637. *)
2457+ Option. iter
2458+ (fun content_length ->
2459+ let file_size = String. length metadata in
2460+ let zero_pad =
2461+ (Tar.Header. length - (file_size mod Tar.Header. length))
2462+ mod Tar.Header. length
2463+ in
2464+ let consumed =
2465+ Tar.Header. length + file_size + zero_pad
2466+ + (Tar.Header. length * 2 )
2467+ in
2468+ let remaining = Int64. to_int content_length - consumed in
2469+ if remaining > 0 then (
2470+ debug " Draining %d remaining body bytes" remaining ;
2471+ (try Tar_helpers. skip s remaining
2472+ with End_of_file -> ()
2473+ )
2474+ )
2475+ )
2476+ req.Request. content_length ;
24552477 let header = metadata |> Xmlrpc. of_string |> header_of_rpc in
24562478 assert_compatible ~__context header.version ;
24572479 if full_restore then
You can’t perform that action at this time.
0 commit comments