From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Aug 21 17:30:02 2007 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04BC716A468 for ; Tue, 21 Aug 2007 17:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CEF5513C46E for ; Tue, 21 Aug 2007 17:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l7LHU11h008757 for ; Tue, 21 Aug 2007 17:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l7LHU1MY008756; Tue, 21 Aug 2007 17:30:01 GMT (envelope-from gnats) Resent-Date: Tue, 21 Aug 2007 17:30:01 GMT Resent-Message-Id: <200708211730.l7LHU1MY008756@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Eugene M. Kim" Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E307316A420 for ; Tue, 21 Aug 2007 17:25:59 +0000 (UTC) (envelope-from ab@seerajeane.astralblue.net) Received: from purple.the-7.net (purple.the-7.net [IPv6:2001:470:1f01:622:230:48ff:fe23:4c67]) by mx1.freebsd.org (Postfix) with ESMTP id C667013C48D for ; Tue, 21 Aug 2007 17:25:59 +0000 (UTC) (envelope-from ab@seerajeane.astralblue.net) Received: from seerajeane.astralblue.net (seerajeane.astralblue.net [IPv6:2001:470:1f01:623:2e0:81ff:fe51:1e73]) by purple.the-7.net (8.13.8/8.13.8) with ESMTP id l7LHPnQo073763 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Aug 2007 10:25:49 -0700 (PDT) (envelope-from ab@seerajeane.astralblue.net) Received: from seerajeane.astralblue.net (seerajeane.astralblue.net [127.0.0.1]) by seerajeane.astralblue.net (8.14.1/8.14.1) with ESMTP id l7LHPr9c085027 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Aug 2007 10:25:53 -0700 (PDT) (envelope-from ab@seerajeane.astralblue.net) Received: (from ab@localhost) by seerajeane.astralblue.net (8.14.1/8.14.1/Submit) id l7LHLoJn084887; Tue, 21 Aug 2007 10:21:50 -0700 (PDT) (envelope-from ab) Message-Id: <200708211721.l7LHLoJn084887@seerajeane.astralblue.net> Date: Tue, 21 Aug 2007 10:21:50 -0700 (PDT) From: "Eugene M. Kim" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: ports/115692: rdesktop(1) hangs in a tight loop upon sound device close X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "Eugene M. Kim" List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2007 17:30:02 -0000 >Number: 115692 >Category: ports >Synopsis: rdesktop(1) hangs in a tight loop upon sound device close >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Aug 21 17:30:01 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Eugene M. Kim >Release: FreeBSD 7.0-CURRENT i386 >Organization: AstralBlue >Environment: System: FreeBSD seerajeane.astralblue.net 7.0-CURRENT FreeBSD 7.0-CURRENT #1: Sat Jul 28 09:00:00 PDT 2007 ab@seerajeane.astralblue.net:/home/FreeBSD/build/MAIN/obj/home/FreeBSD/build/MAIN/src/sys/PL-SEERAJEANE i386 >Description: Upon server-initiated closure of the sound device, rdesktop(1) hangs in a tight loop if the sound packet buffer is not empty. This usually occurs after a long playback, and is indicated by an endless stream of "ERROR: select: Bad file descriptor" messages on stderr. >How-To-Repeat: Run rdesktop with -r sound:local, and play an MP3 file for about 30 seconds then stop playback. >Fix: Apply the following patch, which forcibly empties the sound packet buffer after closing the sound device. --- patch-rdpsnd_oss.c begins here --- --- rdpsnd_oss.c 2007-08-20 23:20:40.000000000 -0700 +++ rdpsnd_oss.c.new 2007-08-20 23:21:51.000000000 -0700 @@ -51,6 +51,35 @@ } packet_queue[MAX_QUEUE]; static unsigned int queue_hi, queue_lo; +/** Frees the first audio packet in the queue (that is, packet_queue[queue_lo]), + * sending a completion notification back to the server. + * + * @return True if the packet queue has become empty; False otherwise.  + * + * If the packet queue is not empty, queue_lo will point at the next packet to + * play. + */ +static BOOL +packet_done(void) +{ + struct audio_packet *packet = &packet_queue[queue_lo++]; + queue_lo %= MAX_QUEUE; + rdpsnd_send_completion(packet->tick, packet->index); + free(packet->s.data); + return (queue_lo == queue_hi); +} + +/** Discards all audio packets queued, sending completion notifications back to + * the server as necessary. + */ +static void +clear_queue(void) +{ + while (queue_lo != queue_hi) + packet_done(); + g_dsp_busy = False; +} + BOOL wave_out_open(void) { @@ -74,6 +103,7 @@ wave_out_close(void) { close(g_dsp_fd); + clear_queue(); } BOOL @@ -277,9 +307,7 @@ if (elapsed >= (duration * 85) / 100) { - rdpsnd_send_completion(packet->tick, packet->index); - free(out->data); - queue_lo = (queue_lo + 1) % MAX_QUEUE; + packet_done(); started = False; } else --- patch-rdpsnd_oss.c ends here --- >Release-Note: >Audit-Trail: >Unformatted: