From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 208.118.235.0/24 X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 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 D67392023C for ; Thu, 7 Jul 2016 02:20:30 +0000 (UTC) Received: from localhost ([::1]:37032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKyvU-0003kC-9Q for e@80x24.org; Wed, 06 Jul 2016 22:20:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKyvR-0003bb-Oj for dtas-all@nongnu.org; Wed, 06 Jul 2016 22:20:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKyvN-0005Bu-Nm for dtas-all@nongnu.org; Wed, 06 Jul 2016 22:20:25 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:33268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKyvN-0005A1-Hq for dtas-all@nongnu.org; Wed, 06 Jul 2016 22:20:21 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5F9C22023C; Thu, 7 Jul 2016 02:20:18 +0000 (UTC) Date: Thu, 7 Jul 2016 02:20:18 +0000 From: Eric Wong To: dtas-all@nongnu.org Subject: [PATCH] dtas-readahead: cleanup open files on pause Message-ID: <20160707022018.GA17687@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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.21 Precedence: list List-Id: everything related to dtas List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" We must not leave open files lingering when the player pauses, as it could prevent remote filesystems from unmounting. --- It's been a while, a new release should be coming end-of-week or so. bin/dtas-readahead | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/bin/dtas-readahead b/bin/dtas-readahead index 97d5a89..b4b7311 100755 --- a/bin/dtas-readahead +++ b/bin/dtas-readahead @@ -149,8 +149,8 @@ def do_open(path) File.open(path) end +work = {} begin - work = {} cur_pid = nil @todo_ra = @max_ra t0 = DTAS.now @@ -159,13 +159,16 @@ def do_open(path) while @todo_ra > 0 && fp.nil? if current = cur['current'] track = current['infile'].freeze - work[track] ||= fp = do_open(track) + fp = work[track] ||= do_open(track) cur_pid = current['pid'] if fp pos = expand_pid(cur_pid).map do |pid| seek_to_cur_pos(pid, fp) end.compact.max - pos and fp = do_ra(fp, pos, w) + if pos + fp = do_ra(fp, pos, w) + work.delete_if { |_, io| io.closed? } + end end else break @@ -176,10 +179,11 @@ def do_open(path) while @todo_ra > 0 && track = queue.shift fp = nil begin - work[track] ||= fp = do_open(track) + fp = work[track] ||= do_open(track) rescue SystemCallError end fp = do_ra(fp, 0, w) if fp + work.delete_if { |_, io| io.closed? } end break if @todo_ra <= 0 @@ -192,10 +196,11 @@ def do_open(path) fp = nil track = c.req("tl get #{cid}").sub!(/\A1 \d+=/, '').freeze begin - work[track] ||= fp = do_open(track) + fp = work[track] ||= do_open(track) rescue SystemCallError end fp = do_ra(fp, 0, w) if fp + work.delete_if { |_, io| io.closed? } if @todo_ra > 0 && fp.nil? && ids[idx += 1].nil? idx = repeat == 'true' ? 0 : nil end @@ -210,7 +215,9 @@ def do_open(path) timeout = 5 - elapsed timeout = 0 if timeout < 0 else - timeout = nil + work.each_value(&:close).clear + fp.close if fp && !fp.closed? + fp = timeout = nil end r = wait_read(w, timeout) p w.res_wait if r -- EW