mirror of
https://github.com/minetest/minetest.git
synced 2024-12-24 23:22:24 +01:00
Fix Result of processed Request was written to invalid (non existent) ResultQueue if requesting thread timed out before
This commit is contained in:
parent
eadc943159
commit
b2d9205796
@ -477,21 +477,24 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We're gonna ask the result to be put into here
|
// We're gonna ask the result to be put into here
|
||||||
ResultQueue<std::string, ClientCached*, u8, u8> result_queue;
|
static ResultQueue<std::string, ClientCached*, u8, u8> result_queue;
|
||||||
|
|
||||||
// Throw a request in
|
// Throw a request in
|
||||||
m_get_clientcached_queue.add(name, 0, 0, &result_queue);
|
m_get_clientcached_queue.add(name, 0, 0, &result_queue);
|
||||||
try{
|
try{
|
||||||
|
while(true) {
|
||||||
// Wait result for a second
|
// Wait result for a second
|
||||||
GetResult<std::string, ClientCached*, u8, u8>
|
GetResult<std::string, ClientCached*, u8, u8>
|
||||||
result = result_queue.pop_front(1000);
|
result = result_queue.pop_front(1000);
|
||||||
// Check that at least something worked OK
|
|
||||||
assert(result.key == name);
|
if (result.key == name) {
|
||||||
// Return it
|
|
||||||
return result.item;
|
return result.item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
catch(ItemNotFoundException &e)
|
catch(ItemNotFoundException &e)
|
||||||
{
|
{
|
||||||
errorstream<<"Waiting for clientcached timed out."<<std::endl;
|
errorstream<<"Waiting for clientcached " << name << " timed out."<<std::endl;
|
||||||
return &m_dummy_clientcached;
|
return &m_dummy_clientcached;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,29 +417,31 @@ u32 ShaderSource::getShaderId(const std::string &name)
|
|||||||
if(get_current_thread_id() == m_main_thread){
|
if(get_current_thread_id() == m_main_thread){
|
||||||
return getShaderIdDirect(name);
|
return getShaderIdDirect(name);
|
||||||
} else {
|
} else {
|
||||||
infostream<<"getShaderId(): Queued: name=\""<<name<<"\""<<std::endl;
|
/*errorstream<<"getShaderId(): Queued: name=\""<<name<<"\""<<std::endl;*/
|
||||||
|
|
||||||
// We're gonna ask the result to be put into here
|
// We're gonna ask the result to be put into here
|
||||||
ResultQueue<std::string, u32, u8, u8> result_queue;
|
|
||||||
|
static ResultQueue<std::string, u32, u8, u8> result_queue;
|
||||||
|
|
||||||
// Throw a request in
|
// Throw a request in
|
||||||
m_get_shader_queue.add(name, 0, 0, &result_queue);
|
m_get_shader_queue.add(name, 0, 0, &result_queue);
|
||||||
|
|
||||||
infostream<<"Waiting for shader from main thread, name=\""
|
/* infostream<<"Waiting for shader from main thread, name=\""
|
||||||
<<name<<"\""<<std::endl;
|
<<name<<"\""<<std::endl;*/
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
while(true) {
|
||||||
// Wait result for a second
|
// Wait result for a second
|
||||||
GetResult<std::string, u32, u8, u8>
|
GetResult<std::string, u32, u8, u8>
|
||||||
result = result_queue.pop_front(1000);
|
result = result_queue.pop_front(1000);
|
||||||
|
|
||||||
// Check that at least something worked OK
|
if (result.key == name) {
|
||||||
assert(result.key == name);
|
|
||||||
|
|
||||||
return result.item;
|
return result.item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
catch(ItemNotFoundException &e){
|
catch(ItemNotFoundException &e){
|
||||||
infostream<<"Waiting for shader timed out."<<std::endl;
|
errorstream<<"Waiting for shader " << name << " timed out."<<std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,10 +543,10 @@ void ShaderSource::processQueue()
|
|||||||
GetRequest<std::string, u32, u8, u8>
|
GetRequest<std::string, u32, u8, u8>
|
||||||
request = m_get_shader_queue.pop();
|
request = m_get_shader_queue.pop();
|
||||||
|
|
||||||
/*infostream<<"ShaderSource::processQueue(): "
|
/**errorstream<<"ShaderSource::processQueue(): "
|
||||||
<<"got shader request with "
|
<<"got shader request with "
|
||||||
<<"name=\""<<request.key<<"\""
|
<<"name=\""<<request.key<<"\""
|
||||||
<<std::endl;*/
|
<<std::endl;**/
|
||||||
|
|
||||||
m_get_shader_queue.pushResult(request,getShaderIdDirect(request.key));
|
m_get_shader_queue.pushResult(request,getShaderIdDirect(request.key));
|
||||||
}
|
}
|
||||||
|
15
src/tile.cpp
15
src/tile.cpp
@ -512,28 +512,29 @@ u32 TextureSource::getTextureId(const std::string &name)
|
|||||||
infostream<<"getTextureId(): Queued: name=\""<<name<<"\""<<std::endl;
|
infostream<<"getTextureId(): Queued: name=\""<<name<<"\""<<std::endl;
|
||||||
|
|
||||||
// We're gonna ask the result to be put into here
|
// We're gonna ask the result to be put into here
|
||||||
ResultQueue<std::string, u32, u8, u8> result_queue;
|
static ResultQueue<std::string, u32, u8, u8> result_queue;
|
||||||
|
|
||||||
// Throw a request in
|
// Throw a request in
|
||||||
m_get_texture_queue.add(name, 0, 0, &result_queue);
|
m_get_texture_queue.add(name, 0, 0, &result_queue);
|
||||||
|
|
||||||
infostream<<"Waiting for texture from main thread, name=\""
|
/*infostream<<"Waiting for texture from main thread, name=\""
|
||||||
<<name<<"\""<<std::endl;
|
<<name<<"\""<<std::endl;*/
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
while(true) {
|
||||||
// Wait result for a second
|
// Wait result for a second
|
||||||
GetResult<std::string, u32, u8, u8>
|
GetResult<std::string, u32, u8, u8>
|
||||||
result = result_queue.pop_front(1000);
|
result = result_queue.pop_front(1000);
|
||||||
|
|
||||||
// Check that at least something worked OK
|
if (result.key == name) {
|
||||||
assert(result.key == name);
|
|
||||||
|
|
||||||
return result.item;
|
return result.item;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
catch(ItemNotFoundException &e)
|
catch(ItemNotFoundException &e)
|
||||||
{
|
{
|
||||||
infostream<<"Waiting for texture timed out."<<std::endl;
|
errorstream<<"Waiting for texture " << name << " timed out."<<std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user