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

Side by Side Diff: handler/handler_main.cc

Issue 1563683002: Allow disabling upload rate-limiting (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: rebase Created 4 years, 11 months 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 | « handler/crashpad_handler.ad ('k') | 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void Usage(const base::FilePath& me) { 67 void Usage(const base::FilePath& me) {
68 fprintf(stderr, 68 fprintf(stderr,
69 "Usage: %" PRFilePath " [OPTION]...\n" 69 "Usage: %" PRFilePath " [OPTION]...\n"
70 "Crashpad's exception handler server.\n" 70 "Crashpad's exception handler server.\n"
71 "\n" 71 "\n"
72 " --annotation=KEY=VALUE set a process annotation in each crash report\n" 72 " --annotation=KEY=VALUE set a process annotation in each crash report\n"
73 " --database=PATH store the crash report database at PATH\n" 73 " --database=PATH store the crash report database at PATH\n"
74 #if defined(OS_MACOSX) 74 #if defined(OS_MACOSX)
75 " --handshake-fd=FD establish communication with the client over FD\n " 75 " --handshake-fd=FD establish communication with the client over FD\n "
76 " --mach-service=SERVICE register SERVICE with the bootstrap server\n" 76 " --mach-service=SERVICE register SERVICE with the bootstrap server\n"
77 #elif defined(OS_WIN)
78 " --handshake-handle=HANDLE\n"
79 " create a new pipe and send its name via HANDLE\n"
80 #endif // OS_MACOSX
81 " --no-rate-limit don't rate limit crash uploads\n"
82 #if defined(OS_MACOSX)
77 " --reset-own-crash-exception-port-to-system-default\n" 83 " --reset-own-crash-exception-port-to-system-default\n"
78 " reset the server's exception handler to default\n " 84 " reset the server's exception handler to default\n "
79 #elif defined(OS_WIN) 85 #elif defined(OS_WIN)
80 " --handshake-handle=HANDLE\n"
81 " create a new pipe and send its name via HANDLE\n"
82 " --pipe-name=PIPE communicate with the client over PIPE\n" 86 " --pipe-name=PIPE communicate with the client over PIPE\n"
83 #endif // OS_MACOSX 87 #endif // OS_MACOSX
84 " --url=URL send crash reports to this Breakpad server URL,\n " 88 " --url=URL send crash reports to this Breakpad server URL,\n "
85 " only if uploads are enabled for the database\n" 89 " only if uploads are enabled for the database\n"
86 " --help display this help and exit\n" 90 " --help display this help and exit\n"
87 " --version output version information and exit\n", 91 " --version output version information and exit\n",
88 me.value().c_str()); 92 me.value().c_str());
89 ToolSupport::UsageTail(me); 93 ToolSupport::UsageTail(me);
90 } 94 }
91 95
(...skipping 30 matching lines...) Expand all
122 const base::FilePath me(argv0.BaseName()); 126 const base::FilePath me(argv0.BaseName());
123 127
124 enum OptionFlags { 128 enum OptionFlags {
125 // Long options without short equivalents. 129 // Long options without short equivalents.
126 kOptionLastChar = 255, 130 kOptionLastChar = 255,
127 kOptionAnnotation, 131 kOptionAnnotation,
128 kOptionDatabase, 132 kOptionDatabase,
129 #if defined(OS_MACOSX) 133 #if defined(OS_MACOSX)
130 kOptionHandshakeFD, 134 kOptionHandshakeFD,
131 kOptionMachService, 135 kOptionMachService,
136 #elif defined(OS_WIN)
137 kOptionHandshakeHandle,
138 #endif // OS_MACOSX
139 kOptionNoRateLimit,
140 #if defined(OS_MACOSX)
132 kOptionResetOwnCrashExceptionPortToSystemDefault, 141 kOptionResetOwnCrashExceptionPortToSystemDefault,
133 #elif defined(OS_WIN) 142 #elif defined(OS_WIN)
134 kOptionHandshakeHandle,
135 kOptionPipeName, 143 kOptionPipeName,
136 #endif // OS_MACOSX 144 #endif // OS_MACOSX
137 kOptionURL, 145 kOptionURL,
138 146
139 // Standard options. 147 // Standard options.
140 kOptionHelp = -2, 148 kOptionHelp = -2,
141 kOptionVersion = -3, 149 kOptionVersion = -3,
142 }; 150 };
143 151
144 struct { 152 struct {
145 std::map<std::string, std::string> annotations; 153 std::map<std::string, std::string> annotations;
146 std::string url; 154 std::string url;
147 const char* database; 155 const char* database;
148 #if defined(OS_MACOSX) 156 #if defined(OS_MACOSX)
149 int handshake_fd; 157 int handshake_fd;
150 std::string mach_service; 158 std::string mach_service;
151 bool reset_own_crash_exception_port_to_system_default; 159 bool reset_own_crash_exception_port_to_system_default;
152 #elif defined(OS_WIN) 160 #elif defined(OS_WIN)
153 HANDLE handshake_handle; 161 HANDLE handshake_handle;
154 std::string pipe_name; 162 std::string pipe_name;
155 #endif // OS_MACOSX 163 #endif // OS_MACOSX
164 bool rate_limit;
156 } options = {}; 165 } options = {};
157 #if defined(OS_MACOSX) 166 #if defined(OS_MACOSX)
158 options.handshake_fd = -1; 167 options.handshake_fd = -1;
159 #elif defined(OS_WIN) 168 #elif defined(OS_WIN)
160 options.handshake_handle = INVALID_HANDLE_VALUE; 169 options.handshake_handle = INVALID_HANDLE_VALUE;
161 #endif 170 #endif
171 options.rate_limit = true;
162 172
163 const option long_options[] = { 173 const option long_options[] = {
164 {"annotation", required_argument, nullptr, kOptionAnnotation}, 174 {"annotation", required_argument, nullptr, kOptionAnnotation},
165 {"database", required_argument, nullptr, kOptionDatabase}, 175 {"database", required_argument, nullptr, kOptionDatabase},
166 #if defined(OS_MACOSX) 176 #if defined(OS_MACOSX)
167 {"handshake-fd", required_argument, nullptr, kOptionHandshakeFD}, 177 {"handshake-fd", required_argument, nullptr, kOptionHandshakeFD},
168 {"mach-service", required_argument, nullptr, kOptionMachService}, 178 {"mach-service", required_argument, nullptr, kOptionMachService},
179 #elif defined(OS_WIN)
180 {"handshake-handle", required_argument, nullptr, kOptionHandshakeHandle},
181 #endif // OS_MACOSX
182 {"no-rate-limit", no_argument, nullptr, kOptionNoRateLimit},
183 #if defined(OS_MACOSX)
169 {"reset-own-crash-exception-port-to-system-default", 184 {"reset-own-crash-exception-port-to-system-default",
170 no_argument, 185 no_argument,
171 nullptr, 186 nullptr,
172 kOptionResetOwnCrashExceptionPortToSystemDefault}, 187 kOptionResetOwnCrashExceptionPortToSystemDefault},
173 #elif defined(OS_WIN) 188 #elif defined(OS_WIN)
174 {"handshake-handle", required_argument, nullptr, kOptionHandshakeHandle},
175 {"pipe-name", required_argument, nullptr, kOptionPipeName}, 189 {"pipe-name", required_argument, nullptr, kOptionPipeName},
176 #endif // OS_MACOSX 190 #endif // OS_MACOSX
177 {"url", required_argument, nullptr, kOptionURL}, 191 {"url", required_argument, nullptr, kOptionURL},
178 {"help", no_argument, nullptr, kOptionHelp}, 192 {"help", no_argument, nullptr, kOptionHelp},
179 {"version", no_argument, nullptr, kOptionVersion}, 193 {"version", no_argument, nullptr, kOptionVersion},
180 {nullptr, 0, nullptr, 0}, 194 {nullptr, 0, nullptr, 0},
181 }; 195 };
182 196
183 int opt; 197 int opt;
184 while ((opt = getopt_long(argc, argv, "", long_options, nullptr)) != -1) { 198 while ((opt = getopt_long(argc, argv, "", long_options, nullptr)) != -1) {
(...skipping 23 matching lines...) Expand all
208 ToolSupport::UsageHint(me, 222 ToolSupport::UsageHint(me,
209 "--handshake-fd requires a file descriptor"); 223 "--handshake-fd requires a file descriptor");
210 return EXIT_FAILURE; 224 return EXIT_FAILURE;
211 } 225 }
212 break; 226 break;
213 } 227 }
214 case kOptionMachService: { 228 case kOptionMachService: {
215 options.mach_service = optarg; 229 options.mach_service = optarg;
216 break; 230 break;
217 } 231 }
218 case kOptionResetOwnCrashExceptionPortToSystemDefault: {
219 options.reset_own_crash_exception_port_to_system_default = true;
220 break;
221 }
222 #elif defined(OS_WIN) 232 #elif defined(OS_WIN)
223 case kOptionHandshakeHandle: { 233 case kOptionHandshakeHandle: {
224 // Use unsigned int, because the handle was presented by the client in 234 // Use unsigned int, because the handle was presented by the client in
225 // 0x%x format. 235 // 0x%x format.
226 unsigned int handle_uint; 236 unsigned int handle_uint;
227 if (!StringToNumber(optarg, &handle_uint) || 237 if (!StringToNumber(optarg, &handle_uint) ||
228 (options.handshake_handle = IntToHandle(handle_uint)) == 238 (options.handshake_handle = IntToHandle(handle_uint)) ==
229 INVALID_HANDLE_VALUE) { 239 INVALID_HANDLE_VALUE) {
230 ToolSupport::UsageHint(me, "--handshake-handle requires a HANDLE"); 240 ToolSupport::UsageHint(me, "--handshake-handle requires a HANDLE");
231 return EXIT_FAILURE; 241 return EXIT_FAILURE;
232 } 242 }
233 break; 243 break;
234 } 244 }
245 #endif // OS_MACOSX
246 case kOptionNoRateLimit: {
247 options.rate_limit = false;
248 break;
249 }
250 #if defined(OS_MACOSX)
251 case kOptionResetOwnCrashExceptionPortToSystemDefault: {
252 options.reset_own_crash_exception_port_to_system_default = true;
253 break;
254 }
255 #elif defined(OS_WIN)
235 case kOptionPipeName: { 256 case kOptionPipeName: {
236 options.pipe_name = optarg; 257 options.pipe_name = optarg;
237 break; 258 break;
238 } 259 }
239 #endif // OS_MACOSX 260 #endif // OS_MACOSX
240 case kOptionURL: { 261 case kOptionURL: {
241 options.url = optarg; 262 options.url = optarg;
242 break; 263 break;
243 } 264 }
244 case kOptionHelp: { 265 case kOptionHelp: {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 386 }
366 #endif // OS_MACOSX 387 #endif // OS_MACOSX
367 388
368 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize( 389 scoped_ptr<CrashReportDatabase> database(CrashReportDatabase::Initialize(
369 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType( 390 base::FilePath(ToolSupport::CommandLineArgumentToFilePathStringType(
370 options.database)))); 391 options.database))));
371 if (!database) { 392 if (!database) {
372 return EXIT_FAILURE; 393 return EXIT_FAILURE;
373 } 394 }
374 395
375 CrashReportUploadThread upload_thread(database.get(), options.url); 396 // TODO(scottmg): options.rate_limit should be removed when we have a
397 // configurable database setting to control upload limiting.
398 // See https://crashpad.chromium.org/bug/23.
399 CrashReportUploadThread upload_thread(
400 database.get(), options.url, options.rate_limit);
376 upload_thread.Start(); 401 upload_thread.Start();
377 402
378 PruneCrashReportThread prune_thread(database.get(), 403 PruneCrashReportThread prune_thread(database.get(),
379 PruneCondition::GetDefault()); 404 PruneCondition::GetDefault());
380 prune_thread.Start(); 405 prune_thread.Start();
381 406
382 CrashReportExceptionHandler exception_handler( 407 CrashReportExceptionHandler exception_handler(
383 database.get(), &upload_thread, &options.annotations); 408 database.get(), &upload_thread, &options.annotations);
384 409
385 exception_handler_server.Run(&exception_handler); 410 exception_handler_server.Run(&exception_handler);
386 411
387 upload_thread.Stop(); 412 upload_thread.Stop();
388 prune_thread.Stop(); 413 prune_thread.Stop();
389 414
390 return EXIT_SUCCESS; 415 return EXIT_SUCCESS;
391 } 416 }
392 417
393 } // namespace crashpad 418 } // namespace crashpad
OLDNEW
« no previous file with comments | « handler/crashpad_handler.ad ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698