зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1477563 - Deep copy file descriptor sets when copying IPDL messages, r=froydnj.
--HG-- extra : rebase_source : 6a002c9af0b12d1015159a3ce841376af13ee284
This commit is contained in:
Родитель
83d770739d
Коммит
b073b2dd5f
|
@ -35,6 +35,15 @@ FileDescriptorSet::~FileDescriptorSet() {
|
|||
}
|
||||
}
|
||||
|
||||
void FileDescriptorSet::CopyFrom(const FileDescriptorSet& other)
|
||||
{
|
||||
for (std::vector<base::FileDescriptor>::const_iterator
|
||||
i = other.descriptors_.begin(); i != other.descriptors_.end(); ++i) {
|
||||
int fd = IGNORE_EINTR(dup(i->fd));
|
||||
AddAndAutoClose(fd);
|
||||
}
|
||||
}
|
||||
|
||||
bool FileDescriptorSet::Add(int fd) {
|
||||
if (descriptors_.size() == MAX_DESCRIPTORS_PER_MESSAGE)
|
||||
return false;
|
||||
|
|
|
@ -29,6 +29,8 @@ class FileDescriptorSet {
|
|||
MAX_DESCRIPTORS_PER_MESSAGE = 250
|
||||
};
|
||||
|
||||
void CopyFrom(const FileDescriptorSet& other);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Interfaces for building during message serialisation...
|
||||
|
||||
|
|
|
@ -148,7 +148,11 @@ Message& Message::operator=(Message&& other) {
|
|||
void Message::CopyFrom(const Message& other) {
|
||||
Pickle::CopyFrom(other);
|
||||
#if defined(OS_POSIX)
|
||||
file_descriptor_set_ = other.file_descriptor_set_;
|
||||
MOZ_ASSERT(!file_descriptor_set_);
|
||||
if (other.file_descriptor_set_) {
|
||||
file_descriptor_set_ = new FileDescriptorSet;
|
||||
file_descriptor_set_->CopyFrom(*other.file_descriptor_set_);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче