[PATCH] ALSA: pcm: Properly close timer when freeing slaves

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Here's a patch originally from Dan McCombs against alsa-lib.git HEAD
fixing a fairly nasty fd leak for timers.

Thanks,
Dan
From f3109e7a1202ca81d545bed45d984926495f6699 Mon Sep 17 00:00:00 2001
From: Daniel T Chen <crimsun@xxxxxxxxxx>
Date: Sun, 20 Dec 2009 15:13:39 -0500
Subject: [PATCH] ALSA: pcm: Properly close timer when freeing slaves

BugLink: https://bugs.launchpad.net/bugs/451893

Dan McCombs discovered that snd_pcm_close() invocations are not leading
to associated timers being closed, which results in successively more
timers being created but not freed.

Signed-off-by: Daniel T Chen <crimsun@xxxxxxxxxx>
---
 src/pcm/pcm_hw.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 2095b01..9444a61 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -338,9 +338,18 @@ static int snd_pcm_hw_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
 	return 0;
 }
 
+static void snd_pcm_hw_close_timer(snd_pcm_hw_t *hw)
+{
+	if (hw->period_timer) {
+		snd_timer_close(hw->period_timer);
+		hw->period_timer = NULL;
+	}
+}
+
 static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)
 {
 	snd_pcm_hw_t *hw = pcm->private_data;
+	snd_pcm_hw_close_timer(hw);
 	int fd = hw->fd, err;
 	if (ioctl(fd, SNDRV_PCM_IOCTL_HW_FREE) < 0) {
 		err = -errno;
@@ -350,14 +359,6 @@ static int snd_pcm_hw_hw_free(snd_pcm_t *pcm)
 	return 0;
 }
 
-static void snd_pcm_hw_close_timer(snd_pcm_hw_t *hw)
-{
-	if (hw->period_timer) {
-		snd_timer_close(hw->period_timer);
-		hw->period_timer = NULL;
-	}
-}
-
 static int snd_pcm_hw_change_timer(snd_pcm_t *pcm, int enable)
 {
 	snd_pcm_hw_t *hw = pcm->private_data;
-- 
1.6.5

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux