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

Unified Diff: util/mach/mach_message_server.cc

Issue 756803002: Add a ReceiveLarge parameter to MachMessageServer::Run() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/mach/mach_message_server.h ('k') | util/mach/mach_message_server_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/mach/mach_message_server.cc
diff --git a/util/mach/mach_message_server.cc b/util/mach/mach_message_server.cc
index 5ac9f42e7091e0494d1abb693fcc6343c5be94cf..74a392603d511dba560ee1426181e7ffff573ed5 100644
--- a/util/mach/mach_message_server.cc
+++ b/util/mach/mach_message_server.cc
@@ -16,6 +16,7 @@
#include <limits>
+#include "base/mac/mach_logging.h"
#include "base/mac/scoped_mach_vm.h"
#include "util/misc/clock.h"
@@ -82,6 +83,7 @@ mach_msg_return_t MachMessageServer::Run(Interface* interface,
mach_msg_options_t options,
Persistent persistent,
Nonblocking nonblocking,
+ ReceiveLarge receive_large,
mach_msg_timeout_t timeout_ms) {
options &= ~(MACH_RCV_MSG | MACH_SEND_MSG);
@@ -101,10 +103,16 @@ mach_msg_return_t MachMessageServer::Run(Interface* interface,
deadline = 0;
}
+ if (receive_large == kReceiveLargeResize) {
+ options |= MACH_RCV_LARGE;
+ } else {
+ options &= ~MACH_RCV_LARGE;
+ }
+
mach_msg_size_t trailer_alloc = REQUESTED_TRAILER_SIZE(options);
mach_msg_size_t max_request_size = interface->MachMessageServerRequestSize();
mach_msg_size_t request_alloc = round_page(max_request_size + trailer_alloc);
- mach_msg_size_t request_size = (options & MACH_RCV_LARGE)
+ mach_msg_size_t request_size = (receive_large == kReceiveLargeResize)
? request_alloc
: max_request_size + trailer_alloc;
@@ -135,6 +143,7 @@ mach_msg_return_t MachMessageServer::Run(Interface* interface,
this_request_alloc);
request_header = reinterpret_cast<mach_msg_header_t*>(request_addr);
+ bool run_mach_msg_receive = false;
do {
// If |options| contains MACH_RCV_INTERRUPT, retry mach_msg() in a loop
// when it returns MACH_RCV_INTERRUPTED to recompute |remaining_ms|
@@ -153,11 +162,19 @@ mach_msg_return_t MachMessageServer::Run(Interface* interface,
receive_port,
remaining_ms,
MACH_PORT_NULL);
- } while (kr == MACH_RCV_INTERRUPTED);
+
+ if (kr == MACH_RCV_TOO_LARGE && receive_large == kReceiveLargeIgnore) {
+ MACH_LOG(WARNING, kr) << "mach_msg: ignoring large message";
+ run_mach_msg_receive = true;
+ } else if (kr == MACH_RCV_INTERRUPTED) {
+ run_mach_msg_receive = true;
+ }
+ } while (run_mach_msg_receive);
if (kr == MACH_MSG_SUCCESS) {
request_scoper.swap(trial_request_scoper);
- } else if (kr == MACH_RCV_TOO_LARGE && options & MACH_RCV_LARGE) {
+ } else if (kr == MACH_RCV_TOO_LARGE &&
+ receive_large == kReceiveLargeResize) {
this_request_size =
round_page(request_header->msgh_size + trailer_alloc);
this_request_alloc = this_request_size;
« no previous file with comments | « util/mach/mach_message_server.h ('k') | util/mach/mach_message_server_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698