From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 208.118.235.0/24 X-Spam-Status: No, score=-2.3 required=3.0 tests=AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: dtas-all@80x24.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A61D51F807 for ; Wed, 18 Feb 2015 22:53:45 +0000 (UTC) Received: from localhost ([::1]:53968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YODV3-0000fH-3D for dtas-all@80x24.org; Wed, 18 Feb 2015 17:53:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOD2B-0006VK-Hw for dtas-all@nongnu.org; Wed, 18 Feb 2015 17:23:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOD27-0001Ex-GQ for dtas-all@nongnu.org; Wed, 18 Feb 2015 17:23:55 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:53165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOD27-0001Ej-AH for dtas-all@nongnu.org; Wed, 18 Feb 2015 17:23:51 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5CA011F7CD for ; Wed, 18 Feb 2015 22:23:49 +0000 (UTC) From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH 1/2] buffer/splice: prepare for IO::Splice::WAITALL removal Date: Wed, 18 Feb 2015 22:23:48 +0000 Message-Id: <1424298229-17600-1-git-send-email-e@80x24.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.71.152.64 X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+dtas-all=80x24.org@nongnu.org Sender: dtas-all-bounces+dtas-all=80x24.org@nongnu.org This feature in the io_splice was probably a bad idea and slated for removal at some point in the future. Anyways, do not rely on it since it is undocumented. --- lib/dtas/buffer/splice.rb | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/dtas/buffer/splice.rb b/lib/dtas/buffer/splice.rb index c83b87b..b987f3a 100644 --- a/lib/dtas/buffer/splice.rb +++ b/lib/dtas/buffer/splice.rb @@ -12,7 +12,6 @@ module DTAS::Buffer::Splice # :nodoc: MAX_SIZE = File.read("/proc/sys/fs/pipe-max-size").to_i DEVNULL = File.open("/dev/null", "r+") F_MOVE = IO::Splice::F_MOVE - WAITALL = IO::Splice::WAITALL def buffer_size @to_io.pipe_size @@ -44,6 +43,26 @@ def broadcast_one(targets) nil # do not return error here, we already spewed an error message end + def __tee_in_full(src, dst, bytes) + rv = 0 + while bytes > 0 + s = IO.tee(src, dst, bytes) + bytes -= s + rv += s + end + rv + end + + def __splice_in_full(src, dst, bytes, flags) + rv = 0 + while bytes > 0 + s = IO.splice(src, nil, dst, nil, bytes, flags) + rv += s + bytes -= s + end + rv + end + # returns the largest value we teed def __broadcast_tee(blocked, targets, chunk_size) most_teed = 0 @@ -51,7 +70,7 @@ def __broadcast_tee(blocked, targets, chunk_size) begin t = (dst.nonblock? || most_teed == 0) ? IO.trytee(@to_io, dst, chunk_size) : - IO.tee(@to_io, dst, chunk_size, WAITALL) + __tee_in_full(@to_io, dst, chunk_size) if Integer === t if t > most_teed chunk_size = t if most_teed == 0 @@ -117,7 +136,7 @@ def broadcast_inf(targets) end else # the blocking case is simple - s = IO.splice(@to_io, nil, last, nil, bytes, WAITALL|F_MOVE) + s = __splice_in_full(@to_io, last, bytes, F_MOVE) end @bytes_xfer += s -- EW