mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 10:18:05 +02:00
gallium/osmesa: Fix a race in creating the stmgr.
Noticed while looking at other OSMesa bugs. Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
parent
281466332b
commit
9e7eb9780a
1 changed files with 17 additions and 9 deletions
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <c11/threads.h>
|
||||
#include "GL/osmesa.h"
|
||||
|
||||
#include "glapi/glapi.h" /* for OSMesaGetProcAddress below */
|
||||
|
|
@ -149,6 +150,18 @@ get_st_api(void)
|
|||
return stapi;
|
||||
}
|
||||
|
||||
static struct st_manager *stmgr = NULL;
|
||||
|
||||
static void
|
||||
create_st_manager(void)
|
||||
{
|
||||
stmgr = CALLOC_STRUCT(st_manager);
|
||||
if (stmgr) {
|
||||
stmgr->screen = osmesa_create_screen();
|
||||
stmgr->get_param = osmesa_st_get_param;
|
||||
stmgr->get_egl_image = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create/return a singleton st_manager object.
|
||||
|
|
@ -156,15 +169,10 @@ get_st_api(void)
|
|||
static struct st_manager *
|
||||
get_st_manager(void)
|
||||
{
|
||||
static struct st_manager *stmgr = NULL;
|
||||
if (!stmgr) {
|
||||
stmgr = CALLOC_STRUCT(st_manager);
|
||||
if (stmgr) {
|
||||
stmgr->screen = osmesa_create_screen();
|
||||
stmgr->get_param = osmesa_st_get_param;
|
||||
stmgr->get_egl_image = NULL;
|
||||
}
|
||||
}
|
||||
static once_flag create_once_flag = ONCE_FLAG_INIT;
|
||||
|
||||
call_once(&create_once_flag, create_st_manager);
|
||||
|
||||
return stmgr;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue