OLD | NEW |
---|---|
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 mach_msg_size_t request_alloc = round_page(max_request_size + trailer_alloc); | 126 mach_msg_size_t request_alloc = round_page(max_request_size + trailer_alloc); |
127 mach_msg_size_t request_size = (options & MACH_RCV_LARGE) | 127 mach_msg_size_t request_size = (options & MACH_RCV_LARGE) |
128 ? request_alloc | 128 ? request_alloc |
129 : max_request_size + trailer_alloc; | 129 : max_request_size + trailer_alloc; |
130 | 130 |
131 mach_msg_size_t max_reply_size = interface->MachMessageServerReplySize(); | 131 mach_msg_size_t max_reply_size = interface->MachMessageServerReplySize(); |
132 mach_msg_size_t reply_alloc = round_page( | 132 mach_msg_size_t reply_alloc = round_page( |
133 (options & MACH_SEND_TRAILER) ? (max_reply_size + MAX_TRAILER_SIZE) | 133 (options & MACH_SEND_TRAILER) ? (max_reply_size + MAX_TRAILER_SIZE) |
134 : max_reply_size); | 134 : max_reply_size); |
135 | 135 |
136 mach_port_t self = mach_task_self(); | |
Mark Mentovai
2014/09/18 16:16:13
This was the only place in bpoop where mach_task_s
| |
137 | |
138 kern_return_t kr; | 136 kern_return_t kr; |
139 | 137 |
140 do { | 138 do { |
141 mach_msg_size_t this_request_alloc = request_alloc; | 139 mach_msg_size_t this_request_alloc = request_alloc; |
142 mach_msg_size_t this_request_size = request_size; | 140 mach_msg_size_t this_request_size = request_size; |
143 | 141 |
144 base::mac::ScopedMachVM request_scoper; | 142 base::mac::ScopedMachVM request_scoper; |
145 mach_msg_header_t* request_header = NULL; | 143 mach_msg_header_t* request_header = NULL; |
146 | 144 |
147 while (!request_scoper.address()) { | 145 while (!request_scoper.address()) { |
148 vm_address_t request_addr; | 146 vm_address_t request_addr; |
149 kr = vm_allocate(self, | 147 kr = vm_allocate(mach_task_self(), |
150 &request_addr, | 148 &request_addr, |
151 this_request_alloc, | 149 this_request_alloc, |
152 VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_MACH_MSG)); | 150 VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_MACH_MSG)); |
153 if (kr != KERN_SUCCESS) { | 151 if (kr != KERN_SUCCESS) { |
154 return kr; | 152 return kr; |
155 } | 153 } |
156 base::mac::ScopedMachVM trial_request_scoper(request_addr, | 154 base::mac::ScopedMachVM trial_request_scoper(request_addr, |
157 this_request_alloc); | 155 this_request_alloc); |
158 request_header = reinterpret_cast<mach_msg_header_t*>(request_addr); | 156 request_header = reinterpret_cast<mach_msg_header_t*>(request_addr); |
159 | 157 |
(...skipping 22 matching lines...) Expand all Loading... | |
182 } else if (kr == MACH_RCV_TOO_LARGE && options & MACH_RCV_LARGE) { | 180 } else if (kr == MACH_RCV_TOO_LARGE && options & MACH_RCV_LARGE) { |
183 this_request_size = | 181 this_request_size = |
184 round_page(request_header->msgh_size + trailer_alloc); | 182 round_page(request_header->msgh_size + trailer_alloc); |
185 this_request_alloc = this_request_size; | 183 this_request_alloc = this_request_size; |
186 } else { | 184 } else { |
187 return kr; | 185 return kr; |
188 } | 186 } |
189 } | 187 } |
190 | 188 |
191 vm_address_t reply_addr; | 189 vm_address_t reply_addr; |
192 kr = vm_allocate(self, | 190 kr = vm_allocate(mach_task_self(), |
193 &reply_addr, | 191 &reply_addr, |
194 reply_alloc, | 192 reply_alloc, |
195 VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_MACH_MSG)); | 193 VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_MACH_MSG)); |
196 if (kr != KERN_SUCCESS) { | 194 if (kr != KERN_SUCCESS) { |
197 return kr; | 195 return kr; |
198 } | 196 } |
199 | 197 |
200 base::mac::ScopedMachVM reply_scoper(reply_addr, reply_alloc); | 198 base::mac::ScopedMachVM reply_scoper(reply_addr, reply_alloc); |
201 | 199 |
202 mach_msg_header_t* reply_header = | 200 mach_msg_header_t* reply_header = |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 // persistent mode, and just return success when not in persistent mode. | 277 // persistent mode, and just return success when not in persistent mode. |
280 return (persistent == kPersistent) ? MACH_RCV_TIMED_OUT : kr; | 278 return (persistent == kPersistent) ? MACH_RCV_TIMED_OUT : kr; |
281 } | 279 } |
282 } | 280 } |
283 } while (persistent == kPersistent); | 281 } while (persistent == kPersistent); |
284 | 282 |
285 return kr; | 283 return kr; |
286 } | 284 } |
287 | 285 |
288 } // namespace crashpad | 286 } // namespace crashpad |
OLD | NEW |