tombstoned: refactor request dequeuing a bit.
Also make it loop, so that upon failing to start a dequeued crash
request, we continue to the next one.
Bug: http://b/36685795
Test: debuggerd_test
Change-Id: I94889125f16f4681c6fa0fa9cac456302602ce01
(cherry picked from commit 807a45807b
)
This commit is contained in:
parent
a1bd1733ae
commit
ef042d3fc5
|
@ -126,7 +126,7 @@ static unique_fd get_tombstone_fd() {
|
|||
return result;
|
||||
}
|
||||
|
||||
static void dequeue_request(Crash* crash) {
|
||||
static void perform_request(Crash* crash) {
|
||||
unique_fd output_fd;
|
||||
if (!intercept_manager->GetIntercept(crash->crash_pid, &output_fd)) {
|
||||
output_fd = get_tombstone_fd();
|
||||
|
@ -159,6 +159,14 @@ fail:
|
|||
delete crash;
|
||||
}
|
||||
|
||||
static void dequeue_requests() {
|
||||
while (!queued_requests.empty() && num_concurrent_dumps < kMaxConcurrentDumps) {
|
||||
Crash* next_crash = queued_requests.front();
|
||||
queued_requests.pop_front();
|
||||
perform_request(next_crash);
|
||||
}
|
||||
}
|
||||
|
||||
static void crash_accept_cb(evconnlistener* listener, evutil_socket_t sockfd, sockaddr*, int,
|
||||
void*) {
|
||||
event_base* base = evconnlistener_get_base(listener);
|
||||
|
@ -207,7 +215,7 @@ static void crash_request_cb(evutil_socket_t sockfd, short ev, void* arg) {
|
|||
LOG(INFO) << "enqueueing crash request for pid " << crash->crash_pid;
|
||||
queued_requests.push_back(crash);
|
||||
} else {
|
||||
dequeue_request(crash);
|
||||
perform_request(crash);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -247,11 +255,7 @@ fail:
|
|||
delete crash;
|
||||
|
||||
// If there's something queued up, let them proceed.
|
||||
if (!queued_requests.empty()) {
|
||||
Crash* next_crash = queued_requests.front();
|
||||
queued_requests.pop_front();
|
||||
dequeue_request(next_crash);
|
||||
}
|
||||
dequeue_requests();
|
||||
}
|
||||
|
||||
int main(int, char* []) {
|
||||
|
|
Loading…
Reference in New Issue