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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 deadline = 0; | 103 deadline = 0; |
104 } | 104 } |
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(); |
Robert Sesek
2014/12/01 21:03:53
Maybe not calling this |max_request_size| would be
| |
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. | |
123 mach_msg_size_t request_size = (receive_large == kReceiveLargeResize) | 115 mach_msg_size_t request_size = (receive_large == kReceiveLargeResize) |
124 ? max_request_size + trailer_alloc | 116 ? request_alloc |
125 : request_alloc; | 117 : max_request_size + trailer_alloc; |
126 | 118 |
127 mach_msg_size_t max_reply_size = interface->MachMessageServerReplySize(); | 119 mach_msg_size_t max_reply_size = interface->MachMessageServerReplySize(); |
128 | 120 |
129 // mach_msg_server() and mach_msg_server_once() would consider whether | 121 // mach_msg_server() and mach_msg_server_once() would consider whether |
130 // |options| contains MACH_SEND_TRAILER and include MAX_TRAILER_SIZE in this | 122 // |options| contains MACH_SEND_TRAILER and include MAX_TRAILER_SIZE in this |
131 // computation if it does, but that option is ineffective on OS X. | 123 // computation if it does, but that option is ineffective on OS X. |
132 mach_msg_size_t reply_alloc = round_page(max_reply_size); | 124 mach_msg_size_t reply_alloc = round_page(max_reply_size); |
133 | 125 |
134 kern_return_t kr; | 126 kern_return_t kr; |
135 | 127 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 // persistent mode, and just return success when not in persistent mode. | 276 // persistent mode, and just return success when not in persistent mode. |
285 return (persistent == kPersistent) ? MACH_RCV_TIMED_OUT : kr; | 277 return (persistent == kPersistent) ? MACH_RCV_TIMED_OUT : kr; |
286 } | 278 } |
287 } | 279 } |
288 } while (persistent == kPersistent); | 280 } while (persistent == kPersistent); |
289 | 281 |
290 return kr; | 282 return kr; |
291 } | 283 } |
292 | 284 |
293 } // namespace crashpad | 285 } // namespace crashpad |
OLD | NEW |