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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 if (receive_large == kReceiveLargeResize) { | 106 if (receive_large == kReceiveLargeResize) { |
107 options |= MACH_RCV_LARGE; | 107 options |= MACH_RCV_LARGE; |
108 } else { | 108 } else { |
109 options &= ~MACH_RCV_LARGE; | 109 options &= ~MACH_RCV_LARGE; |
110 } | 110 } |
111 | 111 |
112 mach_msg_size_t trailer_alloc = REQUESTED_TRAILER_SIZE(options); | 112 mach_msg_size_t trailer_alloc = REQUESTED_TRAILER_SIZE(options); |
113 mach_msg_size_t max_request_size = interface->MachMessageServerRequestSize(); | 113 mach_msg_size_t max_request_size = interface->MachMessageServerRequestSize(); |
114 mach_msg_size_t request_alloc = round_page(max_request_size + trailer_alloc); | 114 mach_msg_size_t request_alloc = round_page(max_request_size + trailer_alloc); |
| 115 |
| 116 // mach_msg_server() and mach_msg_server_once() invert this condition, but |
| 117 // their interpretation is incorrect. When it is desirable to retry a receive |
| 118 // attempt that returns MACH_RCV_TOO_LARGE with a larger receive buffer, it is |
| 119 // also desirable to use the full receive buffer rounded up to a page size for |
| 120 // the initial receive attempt. On the other hand, when this behavior is not |
| 121 // requested, there is no reason to attempt receiving messages any larger than |
| 122 // expected. |
115 mach_msg_size_t request_size = (receive_large == kReceiveLargeResize) | 123 mach_msg_size_t request_size = (receive_large == kReceiveLargeResize) |
116 ? request_alloc | 124 ? max_request_size + trailer_alloc |
117 : max_request_size + trailer_alloc; | 125 : request_alloc; |
118 | 126 |
119 mach_msg_size_t max_reply_size = interface->MachMessageServerReplySize(); | 127 mach_msg_size_t max_reply_size = interface->MachMessageServerReplySize(); |
120 | 128 |
121 // mach_msg_server() and mach_msg_server_once() would consider whether | 129 // mach_msg_server() and mach_msg_server_once() would consider whether |
122 // |options| contains MACH_SEND_TRAILER and include MAX_TRAILER_SIZE in this | 130 // |options| contains MACH_SEND_TRAILER and include MAX_TRAILER_SIZE in this |
123 // computation if it does, but that option is ineffective on OS X. | 131 // computation if it does, but that option is ineffective on OS X. |
124 mach_msg_size_t reply_alloc = round_page(max_reply_size); | 132 mach_msg_size_t reply_alloc = round_page(max_reply_size); |
125 | 133 |
126 kern_return_t kr; | 134 kern_return_t kr; |
127 | 135 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // persistent mode, and just return success when not in persistent mode. | 284 // persistent mode, and just return success when not in persistent mode. |
277 return (persistent == kPersistent) ? MACH_RCV_TIMED_OUT : kr; | 285 return (persistent == kPersistent) ? MACH_RCV_TIMED_OUT : kr; |
278 } | 286 } |
279 } | 287 } |
280 } while (persistent == kPersistent); | 288 } while (persistent == kPersistent); |
281 | 289 |
282 return kr; | 290 return kr; |
283 } | 291 } |
284 | 292 |
285 } // namespace crashpad | 293 } // namespace crashpad |
OLD | NEW |