afs: Fix a fd leak.
authorAndre Noll <maan@systemlinux.org>
Tue, 23 Oct 2007 14:30:05 +0000 (16:30 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 23 Oct 2007 14:30:05 +0000 (16:30 +0200)
afs.c

diff --git a/afs.c b/afs.c
index 0c7526c74110fb59da4cc20b815972421090cc12..901ae00deca346e78a76be2841acccb2feacd4c4 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -468,14 +468,13 @@ int pass_afd(int fd, char *buf, size_t size)
 /**
  * Open the audio file with highest score.
  *
 /**
  * Open the audio file with highest score.
  *
- * \param afd Audio file data is returned here.
+ * This stores all information for streaming the "best" audio file in a shared
+ * memory area. The id of that area and an open file descriptor for the next
+ * audio file are passed to the server process.
  *
  *
- * This stores all information for streaming the "best" audio file
- * in the \a afd structure.
+ * \return Standard.
  *
  *
- * \return Positive on success, negative on errors.
- *
- * \sa close_audio_file(), open_and_update_audio_file().
+ * \sa open_and_update_audio_file().
  */
 int open_next_audio_file(void)
 {
  */
 int open_next_audio_file(void)
 {
@@ -500,6 +499,7 @@ int open_next_audio_file(void)
        *(uint32_t *)buf = NEXT_AUDIO_FILE;
        *(uint32_t *)(buf + 4) = (uint32_t)shmid;
        ret = pass_afd(afd.fd, buf, 8);
        *(uint32_t *)buf = NEXT_AUDIO_FILE;
        *(uint32_t *)(buf + 4) = (uint32_t)shmid;
        ret = pass_afd(afd.fd, buf, 8);
+       close(afd.fd);
        if (ret >= 0)
                return ret;
        PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
        if (ret >= 0)
                return ret;
        PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));