Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: util/mach/mach_message_server.cc

Issue 760573003: Undo a68594234262 (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 expected_request_size =
114 interface->MachMessageServerRequestSize();
114 mach_msg_size_t request_alloc = 115 mach_msg_size_t request_alloc =
115 round_page(round_msg(max_request_size) + trailer_alloc); 116 round_page(round_msg(expected_request_size) + trailer_alloc);
116
117 // mach_msg_server() and mach_msg_server_once() invert this condition, but
118 // their interpretation is incorrect. When it is desirable to retry a receive
119 // attempt that returns MACH_RCV_TOO_LARGE with a larger receive buffer, it is
120 // also desirable to use the full receive buffer rounded up to a page size for
121 // the initial receive attempt. On the other hand, when this behavior is not
122 // requested, there is no reason to attempt receiving messages any larger than
123 // expected.
124 mach_msg_size_t request_size = 117 mach_msg_size_t request_size =
125 (receive_large == kReceiveLargeResize) 118 (receive_large == kReceiveLargeResize)
126 ? round_msg(max_request_size) + trailer_alloc 119 ? request_alloc
127 : request_alloc; 120 : round_msg(expected_request_size) + trailer_alloc;
128 121
129 mach_msg_size_t max_reply_size = interface->MachMessageServerReplySize(); 122 mach_msg_size_t max_reply_size = interface->MachMessageServerReplySize();
130 123
131 // mach_msg_server() and mach_msg_server_once() would consider whether 124 // mach_msg_server() and mach_msg_server_once() would consider whether
132 // |options| contains MACH_SEND_TRAILER and include MAX_TRAILER_SIZE in this 125 // |options| contains MACH_SEND_TRAILER and include MAX_TRAILER_SIZE in this
133 // computation if it does, but that option is ineffective on OS X. 126 // computation if it does, but that option is ineffective on OS X.
134 mach_msg_size_t reply_alloc = round_page(max_reply_size); 127 mach_msg_size_t reply_alloc = round_page(max_reply_size);
135 128
136 kern_return_t kr; 129 kern_return_t kr;
137 130
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // persistent mode, and just return success when not in persistent mode. 279 // persistent mode, and just return success when not in persistent mode.
287 return (persistent == kPersistent) ? MACH_RCV_TIMED_OUT : kr; 280 return (persistent == kPersistent) ? MACH_RCV_TIMED_OUT : kr;
288 } 281 }
289 } 282 }
290 } while (persistent == kPersistent); 283 } while (persistent == kPersistent);
291 284
292 return kr; 285 return kr;
293 } 286 }
294 287
295 } // namespace crashpad 288 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698