Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c96ad66d authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Grab the tracing lock before calling the trace runner

The runner could be called from the binder thread
and the tracing or main thread depending on the
tracing configuration.

Fixes: 180041001
Test: added compile time thread saftey checks and manual tests
Change-Id: I636a6e16e8508cfe3f1672e6a4434b47b664e60f
parent a9b9fe40
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -71,12 +71,14 @@ status_t SurfaceTracing::writeToFile() {
}

void SurfaceTracing::notify(const char* where) {
    std::scoped_lock lock(mTraceLock);
    if (mEnabled) {
        runner->notify(where);
    }
}

void SurfaceTracing::notifyLocked(const char* where) {
    std::scoped_lock lock(mTraceLock);
    if (mEnabled) {
        runner->notifyLocked(where);
    }
+2 −2
Original line number Diff line number Diff line
@@ -81,8 +81,8 @@ private:

    SurfaceFlinger& mFlinger;
    mutable std::mutex mTraceLock;
    bool mEnabled = false;
    std::unique_ptr<Runner> runner;
    bool mEnabled GUARDED_BY(mTraceLock) = false;
    std::unique_ptr<Runner> runner GUARDED_BY(mTraceLock);

    struct Config {
        uint32_t flags = TRACE_CRITICAL | TRACE_INPUT | TRACE_SYNC;