summaryrefslogtreecommitdiffstats
path: root/liboverlay
diff options
context:
space:
mode:
authorhoony.yu <hoony.yu@samsung.com>2010-10-08 12:17:20 -0700
committerSimon Wilson <simonwilson@google.com>2010-10-08 19:53:17 -0700
commit83bf3c1b8e39d11dcd75fbbd5826dede81ff0702 (patch)
tree670cfb9198c5d098f5488240fa38e7bcc20a997d /liboverlay
parentff8195d3c0384ce4efa6a2d804222e3c6dd93157 (diff)
downloaddevice_samsung_crespo-83bf3c1b8e39d11dcd75fbbd5826dede81ff0702.zip
device_samsung_crespo-83bf3c1b8e39d11dcd75fbbd5826dede81ff0702.tar.gz
device_samsung_crespo-83bf3c1b8e39d11dcd75fbbd5826dede81ff0702.tar.bz2
S5PC11X: OVERLAY: Fix a bug related to use a mutex
Change-Id: I3c0a9d17d2688731dd37d5d2b140531f6693b925 Signed-off-by: hoony.yu <hoony.yu@samsung.com>
Diffstat (limited to 'liboverlay')
-rw-r--r--liboverlay/overlay.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index 33cebdf..0ff72dc 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -94,6 +94,7 @@ typedef struct
uint32_t dataReady; /* Only updated by the data side */
pthread_mutex_t lock;
+ pthread_mutexattr_t attr;
uint32_t streamEn;
uint32_t streamingReset;
@@ -287,16 +288,29 @@ static int create_shared_data(overlay_shared_t **shared)
p->marker = SHARED_DATA_MARKER;
p->size = size;
p->refCnt = 1;
-
- if (pthread_mutex_init(&p->lock, NULL) != 0) {
- LOGE("Failed to Open Overlay Lock!\n");
- munmap(p, size);
- close(fd);
- return -1;
+ if (pthread_mutexattr_init(&p->attr) != 0) {
+ LOGE("Failed to initialize overlay mutex attr");
+ goto MutexAttrErr;
+ }
+ if (pthread_mutexattr_setpshared(&p->attr, PTHREAD_PROCESS_SHARED) != 0) {
+ LOGE("Failed to set the overlay mutex attr to be shared across-processes");
+ goto MutexAttrSetErr;
+ }
+ if (pthread_mutex_init(&p->lock, &p->attr) != 0) {
+ LOGE("Failed to initialize overlay mutex\n");
+ goto MutexErr;
}
*shared = p;
return fd;
+
+MutexErr:
+MutexAttrSetErr:
+ pthread_mutexattr_destroy(&p->attr);
+MutexAttrErr:
+ munmap(p, size);
+ close(fd);
+ return -1;
}
static void destroy_shared_data(int shared_fd, overlay_shared_t *shared,
@@ -309,9 +323,12 @@ static void destroy_shared_data(int shared_fd, overlay_shared_t *shared,
/* side will deadlock trying to use an already released mutex */
if (android_atomic_dec(&shared->refCnt) == 1) {
if (pthread_mutex_destroy(&shared->lock)) {
- LOGE("Failed to Close Overlay Semaphore!\n");
+ LOGE("Failed to uninitialize overlay mutex!\n");
}
+ if (pthread_mutexattr_destroy(&shared->attr)) {
+ LOGE("Failed to uninitialize the overlay mutex attr!\n");
+ }
shared->marker = 0;
}