OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ipc/file_descriptor_set_posix.h" | 5 #include "ipc/file_descriptor_set_posix.h" |
6 | 6 |
7 #include <sys/types.h> | 7 #include <sys/types.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 // kernel resources. | 30 // kernel resources. |
31 for (unsigned i = consumed_descriptor_highwater_; | 31 for (unsigned i = consumed_descriptor_highwater_; |
32 i < descriptors_.size(); ++i) { | 32 i < descriptors_.size(); ++i) { |
33 if (descriptors_[i].auto_close) | 33 if (descriptors_[i].auto_close) |
34 if (HANDLE_EINTR(close(descriptors_[i].fd)) < 0) | 34 if (HANDLE_EINTR(close(descriptors_[i].fd)) < 0) |
35 PLOG(ERROR) << "close"; | 35 PLOG(ERROR) << "close"; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 bool FileDescriptorSet::Add(int fd) { | 39 bool FileDescriptorSet::Add(int fd) { |
40 if (descriptors_.size() == kMaxDescriptorsPerMessage) | 40 if (descriptors_.size() == kMaxDescriptorsPerMessage) { |
| 41 DLOG(WARNING) << "Cannot add file descriptor. FileDescriptorSet full."; |
41 return false; | 42 return false; |
| 43 } |
42 | 44 |
43 struct base::FileDescriptor sd; | 45 struct base::FileDescriptor sd; |
44 sd.fd = fd; | 46 sd.fd = fd; |
45 sd.auto_close = false; | 47 sd.auto_close = false; |
46 descriptors_.push_back(sd); | 48 descriptors_.push_back(sd); |
47 return true; | 49 return true; |
48 } | 50 } |
49 | 51 |
50 bool FileDescriptorSet::AddAndAutoClose(int fd) { | 52 bool FileDescriptorSet::AddAndAutoClose(int fd) { |
51 if (descriptors_.size() == kMaxDescriptorsPerMessage) | 53 if (descriptors_.size() == kMaxDescriptorsPerMessage) { |
| 54 DLOG(WARNING) << "Cannot add file descriptor. FileDescriptorSet full."; |
52 return false; | 55 return false; |
| 56 } |
53 | 57 |
54 struct base::FileDescriptor sd; | 58 struct base::FileDescriptor sd; |
55 sd.fd = fd; | 59 sd.fd = fd; |
56 sd.auto_close = true; | 60 sd.auto_close = true; |
57 descriptors_.push_back(sd); | 61 descriptors_.push_back(sd); |
58 DCHECK(descriptors_.size() <= kMaxDescriptorsPerMessage); | 62 DCHECK(descriptors_.size() <= kMaxDescriptorsPerMessage); |
59 return true; | 63 return true; |
60 } | 64 } |
61 | 65 |
62 int FileDescriptorSet::GetDescriptorAt(unsigned index) const { | 66 int FileDescriptorSet::GetDescriptorAt(unsigned index) const { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 DCHECK_EQ(consumed_descriptor_highwater_, 0u); | 132 DCHECK_EQ(consumed_descriptor_highwater_, 0u); |
129 | 133 |
130 descriptors_.reserve(count); | 134 descriptors_.reserve(count); |
131 for (unsigned i = 0; i < count; ++i) { | 135 for (unsigned i = 0; i < count; ++i) { |
132 struct base::FileDescriptor sd; | 136 struct base::FileDescriptor sd; |
133 sd.fd = buffer[i]; | 137 sd.fd = buffer[i]; |
134 sd.auto_close = true; | 138 sd.auto_close = true; |
135 descriptors_.push_back(sd); | 139 descriptors_.push_back(sd); |
136 } | 140 } |
137 } | 141 } |
OLD | NEW |