Bug 977372 - Close IPC'd filedescriptor from device descriptor when finished with it. r=mikeh

This commit is contained in:
Dave Hylands 2014-02-28 12:02:55 -08:00
parent f830bb9b3e
commit c79312959a
2 changed files with 9 additions and 1 deletions

View File

@ -757,7 +757,11 @@ nsDOMCameraControl::OnCreatedFileDescriptor(bool aSucceeded)
return;
}
}
// An error occured. We need to manually close the file descriptor since
// the FileDescriptor destructor doesn't close file handles which originate
// from other processes.
int fd = mDSFileDescriptor->mFileDescriptor.PlatformHandle();
ScopedClose autoClose(fd);
OnError(CameraControlListener::kInStartRecording, NS_LITERAL_STRING("FAILURE"));
}

View File

@ -856,7 +856,11 @@ nsGonkCameraControl::StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescri
}
nsresult rv;
// SetupRecording creates a dup of the file descriptor, and since it
// was created in the parent, the FileDescriptor destructor won't close
// it, so we go ahead and close it once we leave this function.
int fd = aFileDescriptor->mFileDescriptor.PlatformHandle();
ScopedClose autoClose(fd);
if (aOptions) {
rv = SetupRecording(fd, aOptions->rotation, aOptions->maxFileSizeBytes,
aOptions->maxVideoLengthMs);