From b25918ac526a1558aeee9bfbfd2100b22ae611ff Mon Sep 17 00:00:00 2001 From: "Arun Kumar K.R" Date: Wed, 22 Aug 2012 16:09:48 -0700 Subject: [PATCH] hwcomposer: delay starting the uevent thread - There is a race condition window between initializing hwcomposer as a whole and registering callback functions for when the uevents arrive. We can fix this issue by delaying the uevent thread kick off until the callback functions are registered. - Add thread name to uevent thread Change-Id: I30e23b411b92b6578f186b641f562462a8f23179 --- libhwcomposer/hwc.cpp | 3 +++ libhwcomposer/hwc_uevents.cpp | 4 ++++ libhwcomposer/hwc_utils.cpp | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp index af23ecb..c6f4faf 100644 --- a/libhwcomposer/hwc.cpp +++ b/libhwcomposer/hwc.cpp @@ -70,6 +70,9 @@ static void hwc_registerProcs(struct hwc_composer_device* dev, return; } ctx->device.reserved_proc[0] = (void*)procs; + + // Now that we have the functions needed, kick off the uevent thread + init_uevent_thread(ctx); } static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp index 68d01ae..dc94eac 100644 --- a/libhwcomposer/hwc_uevents.cpp +++ b/libhwcomposer/hwc_uevents.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include "hwc_utils.h" @@ -88,6 +89,8 @@ static void *uevent_loop(void *param) memset(udata, 0, sizeof(udata)); hwc_context_t * ctx = reinterpret_cast(param); + char thread_name[64] = "hwcUeventThread"; + prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0); setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); uevent_init(); @@ -102,6 +105,7 @@ static void *uevent_loop(void *param) void init_uevent_thread(hwc_context_t* ctx) { pthread_t uevent_thread; + ALOGI("Initializing UEvent Listener Thread"); pthread_create(&uevent_thread, NULL, uevent_loop, (void*) ctx); } diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp index 258913d..155447a 100644 --- a/libhwcomposer/hwc_utils.cpp +++ b/libhwcomposer/hwc_utils.cpp @@ -54,8 +54,6 @@ void initContext(hwc_context_t *ctx) ctx->mExtDisplay = new ExternalDisplay(ctx); MDPComp::init(ctx); - init_uevent_thread(ctx); - char value[PROPERTY_VALUE_MAX]; property_get("debug.egl.swapinterval", value, "1"); ctx->swapInterval = atoi(value);