MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / fconfig_getinstance

Function fconfig_getinstance

server/fakerconfig.cpp:94–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94FakerConfig *fconfig_getinstance(void)
95{
96 if(fconfig_instance == NULL)
97 {
98 CriticalSection::SafeLock l(fcmutex);
99 if(fconfig_instance == NULL)
100 {
101 #if FCONFIG_USESHM == 1
102
103 void *addr = NULL;
104 if((fconfig_shmid = shmget(IPC_PRIVATE, sizeof(FakerConfig),
105 IPC_CREAT | 0600)) == -1)
106 THROW_UNIX();
107 if((addr = shmat(fconfig_shmid, 0, 0)) == (void *)-1) THROW_UNIX();
108 if(!addr)
109 THROW("Could not attach to config structure in shared memory");
110 #ifndef sun
111 shmctl(fconfig_shmid, IPC_RMID, 0);
112 #endif
113 char *env = NULL;
114 if((env = getenv("VGL_VERBOSE")) != NULL && strlen(env) > 0
115 && !strncmp(env, "1", 1))
116 vglout.println("[VGL] Shared memory segment ID for vglconfig: %d",
117 fconfig_shmid);
118 fconfig_instance = (FakerConfig *)addr;
119
120 #else
121
122 fconfig_instance = new FakerConfig;
123 if(!fconfig_instance) THROW("Could not allocate config structure");
124
125 #endif
126
127 fconfig_init();
128 }
129 }
130 return fconfig_instance;
131}
132
133
134void fconfig_deleteinstance(CriticalSection *mutex)

Callers

nothing calls this directly

Calls 3

getenvFunction · 0.85
fconfig_initFunction · 0.85
printlnMethod · 0.80

Tested by

no test coverage detected