Hello steveblock,
I'd like you to do a code review. Please execute
g4 diff -c 9439364
or point your web browser to
http://mondrian/9439364
to review the following code:
Change 9439364 by andr...@andreip-gearslinux on 2008/12/16 23:17:12 *pending*
Fixes two more problems in Android HTTP Request:
- fixes unsynchronized access to state_ in HandleStateMachine()
- a child may actually branch to COMPLETE as a result of a
concurrent call to Abort() on the main thread. We simply ignore
this state on the child thread.
PRESUBMIT=passed
R=steveblock
[email protected]
DELTA=19 (14 added, 3 deleted, 2 changed)
OCL=9439364
Affected files ...
...
//depot/googleclient/gears/opensource/gears/localserver/android/http_request_android.cc#4
edit
19 delta lines: 14 added, 3 deleted, 2 changed
Also consider running:
g4 lint -c 9439364
which verifies that the changelist doesn't introduce new style violations.
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [email protected].
Change 9439364 by andr...@andreip-gearslinux on 2008/12/16 23:17:12 *pending*
Fixes two more problems in Android HTTP Request:
- fixes unsynchronized access to state_ in HandleStateMachine()
- a child may actually branch to COMPLETE as a result of a
concurrent call to Abort() on the main thread. We simply ignore
this state on the child thread.
Affected files ...
...
//depot/googleclient/gears/opensource/gears/localserver/android/http_request_android.cc#4
edit
====
//depot/googleclient/gears/opensource/gears/localserver/android/http_request_android.cc#4
-
/home/andreip/Gears/googleclient/gears/opensource/gears/localserver/android/http_request_android.cc
====
# action=edit type=text
---
googleclient/gears/opensource/gears/localserver/android/http_request_android.cc
2008-12-16 22:38:51.000000000 +0000
+++
googleclient/gears/opensource/gears/localserver/android/http_request_android.cc
2008-12-16 23:38:50.000000000 +0000
@@ -582,9 +582,6 @@
}
void HttpRequestAndroid::HandleStateMachine() {
- LOG(("Running %s thread in state %s\n",
- IsMainThread() ? "main" : "child",
- GetStateName(state_)));
// Loop the state machine until the current thread is no longer in
// control.
// Note that state transitions happen only in the following circumstances
@@ -612,7 +609,16 @@
// from MAIN_IDLE to some random state.
for (;;) {
- switch (state_) {
+ State local_state;
+ {
+ MutexLock locker(&mutex_);
+ local_state = state_;
+ }
+ LOG(("Running %s thread in state %s\n",
+ IsMainThread() ? "main" : "child",
+ GetStateName(local_state)));
+
+ switch (local_state) {
case STATE_MAIN_IDLE:
assert(IsMainThread());
// Exit the state machine loop.
@@ -754,7 +760,12 @@
}
case STATE_MAIN_COMPLETE:
- assert(IsMainThread());
+ if (IsChildThread()) {
+ // Looks like we've been aborted before we branched here.
+ assert(was_aborted_);
+ break;
+ }
+
// Shut down the child thread now, otherwise we have to wait
// until the last unreference, which may be a long time if it
// is held by a JavaScript HttpRequest instance.