Fix PhysicsServer connection issue, in cases where shared memory was not properly shut down.
This commit is contained in:
@@ -460,34 +460,43 @@ bool PhysicsServerSharedMemory::connectSharedMemory( struct GUIHelperInterface*
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_data->m_testBlock1 = (SharedMemoryBlock*)m_data->m_sharedMemory->allocateSharedMemory(m_data->m_sharedMemoryKey, SHARED_MEMORY_SIZE,allowCreation);
|
int counter = 0;
|
||||||
if (m_data->m_testBlock1)
|
do
|
||||||
{
|
{
|
||||||
int magicId =m_data->m_testBlock1->m_magicId;
|
|
||||||
if (m_data->m_verboseOutput)
|
m_data->m_testBlock1 = (SharedMemoryBlock*)m_data->m_sharedMemory->allocateSharedMemory(m_data->m_sharedMemoryKey, SHARED_MEMORY_SIZE,allowCreation);
|
||||||
|
if (m_data->m_testBlock1)
|
||||||
{
|
{
|
||||||
b3Printf("magicId = %d\n", magicId);
|
int magicId =m_data->m_testBlock1->m_magicId;
|
||||||
}
|
|
||||||
|
|
||||||
if (m_data->m_testBlock1->m_magicId !=SHARED_MEMORY_MAGIC_NUMBER)
|
|
||||||
{
|
|
||||||
InitSharedMemoryBlock(m_data->m_testBlock1);
|
|
||||||
if (m_data->m_verboseOutput)
|
if (m_data->m_verboseOutput)
|
||||||
{
|
{
|
||||||
b3Printf("Created and initialized shared memory block\n");
|
b3Printf("magicId = %d\n", magicId);
|
||||||
}
|
}
|
||||||
m_data->m_isConnected = true;
|
|
||||||
} else
|
if (m_data->m_testBlock1->m_magicId !=SHARED_MEMORY_MAGIC_NUMBER)
|
||||||
|
{
|
||||||
|
InitSharedMemoryBlock(m_data->m_testBlock1);
|
||||||
|
if (m_data->m_verboseOutput)
|
||||||
|
{
|
||||||
|
b3Printf("Created and initialized shared memory block\n");
|
||||||
|
}
|
||||||
|
m_data->m_isConnected = true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
m_data->m_sharedMemory->releaseSharedMemory(m_data->m_sharedMemoryKey, SHARED_MEMORY_SIZE);
|
||||||
|
m_data->m_testBlock1 = 0;
|
||||||
|
m_data->m_isConnected = false;
|
||||||
|
}
|
||||||
|
} else
|
||||||
{
|
{
|
||||||
b3Error("Server cannot connect to existing shared memory, disconnecting shared memory.\n");
|
b3Error("Cannot connect to shared memory");
|
||||||
m_data->m_sharedMemory->releaseSharedMemory(m_data->m_sharedMemoryKey, SHARED_MEMORY_SIZE);
|
m_data->m_isConnected = false;
|
||||||
m_data->m_testBlock1 = 0;
|
|
||||||
m_data->m_isConnected = false;
|
|
||||||
}
|
}
|
||||||
} else
|
} while (counter++ < 10 && !m_data->m_isConnected);
|
||||||
|
|
||||||
|
if (!m_data->m_isConnected)
|
||||||
{
|
{
|
||||||
b3Error("Cannot connect to shared memory");
|
b3Error("Server cannot connect to shared memory.\n");
|
||||||
m_data->m_isConnected = false;
|
|
||||||
}
|
}
|
||||||
return m_data->m_isConnected;
|
return m_data->m_isConnected;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user