summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-09-14 15:12:15 +0200
committerAlexander Larsson <alexl@redhat.com>2010-09-20 10:25:17 +0200
commit578b1e53e623b0d5d69ee6066bae30ddccacac42 (patch)
treef5a4e943bc4f2f07293a9154d25040f6b9f46e90
parent638c5ff7c62a814afc3e0b8929ad85981df02ae9 (diff)
Add semaphore to protect quic_data from concurrent access
-rw-r--r--display/qxldd.h1
-rw-r--r--display/res.c12
2 files changed, 12 insertions, 1 deletions
diff --git a/display/qxldd.h b/display/qxldd.h
index 26528df..d63aa9d 100644
--- a/display/qxldd.h
+++ b/display/qxldd.h
@@ -253,6 +253,7 @@ typedef struct PDev {
UINT8 *surf_base;
QuicData *quic_data;
+ HSEMAPHORE quic_data_sem;
QXLCommandRing *cmd_ring;
QXLCursorRing *cursor_ring;
diff --git a/display/res.c b/display/res.c
index 353c85b..07f8991 100644
--- a/display/res.c
+++ b/display/res.c
@@ -1645,6 +1645,8 @@ static _inline Resource *GetQuicImage(PDev *pdev, SURFOBJ *surf, XLATEOBJ *color
return NULL;
}
+ EngAcquireSemaphore(pdev->quic_data_sem);
+
quic_data = pdev->quic_data;
alloc_size = MIN(QUIC_ALLOC_BASE + (height * line_size >> 4), QUIC_ALLOC_BASE + QUIC_BUF_MAX);
@@ -1676,13 +1678,18 @@ static _inline Resource *GetQuicImage(PDev *pdev, SURFOBJ *surf, XLATEOBJ *color
if (data_size == QUIC_ERROR) {
FreeQuicImage(pdev, image_res);
DEBUG_PRINT((pdev, 13, "%s: error\n", __FUNCTION__));
- return NULL;
+ image_res = NULL;
+ goto out;
}
quic_data->chunk->data_size = (data_size - quic_data->prev_chunks_io_words) << 2;
internal->image.quic.data_size = data_size << 2;
DEBUG_PRINT((pdev, 13, "%s: done. row size %u quic size %u \n", __FUNCTION__,
line_size * height, data_size << 2));
+
+ out:
+ EngReleaseSemaphore(pdev->quic_data_sem);
+
return image_res;
}
@@ -3211,6 +3218,8 @@ BOOL ResInit(PDev *pdev)
return FALSE;
}
pdev->quic_data = usr_data;
+ pdev->quic_data_sem = EngCreateSemaphore();
+
return TRUE;
}
@@ -3218,6 +3227,7 @@ void ResDestroy(PDev *pdev)
{
QuicData *usr_data = pdev->quic_data;
quic_destroy(usr_data->quic);
+ EngDeleteSemaphore(pdev->quic_data_sem);
EngFreeMem(usr_data);
}