Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5225ba06 authored by Bao Haojun's avatar Bao Haojun
Browse files

Fix double close.



This patch will fix the double close issue in SoundPool::doLoad():

        status = MediaPlayer::decode(mFd, mOffset, mLength, &sampleRate, &numChannels, &format,
                                     mHeap, &mSize);
        ALOGV("close(%d)", mFd);
        ::close(mFd);
        mFd = -1;

In MediaPlayerService::decode() which is called directly by
MediaPlayer::decode(), the fd will be closed, and after it return, the
mFd will be closed again.

When the system is idle, the second close will fail with EBADFD, but if
the system is busy, the mFd will be reused with another open/socket/pipe
system call, and the second close will cause errors.

Change-Id: If709515392cd490fea569658202524c51f8df785
Signed-off-by: default avatarBao Haojun <baohaojun@gmail.com>
Signed-off-by: default avatarWang Liang <wangliang@smartisan.cn>
parent 3059e27d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -250,6 +250,7 @@ status_t BnMediaPlayerService::onTransact(
            size_t size;
            status_t status = decode(fd, offset, length, &sampleRate, &numChannels, &format,
                                     heap, &size);
            ::close(fd);
            reply->writeInt32(status);
            if (status == NO_ERROR) {
                reply->writeInt32(sampleRate);
+0 −1
Original line number Diff line number Diff line
@@ -1289,7 +1289,6 @@ status_t MediaPlayerService::decode(int fd, int64_t offset, int64_t length,

Exit:
    if (player != 0) player->reset();
    ::close(fd);
    return status;
}