Lengthen ScopedDisableMallocTimeout timeout to 10 seconds

memunreachable_unit_test is flaking sometimes with timeouts in
ScopedDisableMallocTimeout.  They can't be real deadlocks, which
is what this timeout is designed to detect, the Enable() called
from the signal handler wasn't doing anything because disabled_
hadn't been set yet.

Lengthen the timeout to 10 seconds, and set disabled_ before
starting to take the malloc locks in malloc_disable.  If this
really deadlocked then calling malloc_enable inside malloc_disable
would make a mess of the locks, but it would at least unlock
whatever lock was deadlocked and give the test a chance to
report the error.

Bug: 141229513
Test: atest memunreachable_unit_test
Change-Id: I3578964577025aaa4bbba09027afd22997d4adbd
diff --git a/ScopedDisableMalloc.h b/ScopedDisableMalloc.h
index 655e826..dc863c9 100644
--- a/ScopedDisableMalloc.h
+++ b/ScopedDisableMalloc.h
@@ -34,8 +34,8 @@
 
   void Disable() {
     if (!disabled_) {
-      malloc_disable();
       disabled_ = true;
+      malloc_disable();
     }
   }
 
@@ -71,8 +71,7 @@
 
 class ScopedDisableMallocTimeout {
  public:
-  explicit ScopedDisableMallocTimeout(
-      std::chrono::milliseconds timeout = std::chrono::milliseconds(2000))
+  explicit ScopedDisableMallocTimeout(std::chrono::milliseconds timeout = std::chrono::seconds(10))
       : timeout_(timeout), timed_out_(false), disable_malloc_() {
     Disable();
   }