diff options
author | sapier <Sapier at GMX dot net> | 2013-11-14 18:30:43 +0100 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2013-11-17 12:46:54 -0500 |
commit | b2d9205796eef23fd5d9a436d438fa2ca31ec21a (patch) | |
tree | 01940565ac2cf70f6e1d70c7a38227fbd17c2e7d /src/itemdef.cpp | |
parent | eadc9431592f1e21a9211c3487334cd31ed54db1 (diff) | |
download | minetest-b2d9205796eef23fd5d9a436d438fa2ca31ec21a.tar.gz minetest-b2d9205796eef23fd5d9a436d438fa2ca31ec21a.tar.bz2 minetest-b2d9205796eef23fd5d9a436d438fa2ca31ec21a.zip |
Fix Result of processed Request was written to invalid (non existent) ResultQueue if requesting thread timed out before
Diffstat (limited to 'src/itemdef.cpp')
-rw-r--r-- | src/itemdef.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/itemdef.cpp b/src/itemdef.cpp index c520ea902..d34d68582 100644 --- a/src/itemdef.cpp +++ b/src/itemdef.cpp @@ -477,21 +477,24 @@ public: else { // 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 m_get_clientcached_queue.add(name, 0, 0, &result_queue); try{ - // Wait result for a second - GetResult<std::string, ClientCached*, u8, u8> + while(true) { + // Wait result for a second + GetResult<std::string, ClientCached*, u8, u8> result = result_queue.pop_front(1000); - // Check that at least something worked OK - assert(result.key == name); - // Return it - return result.item; + + if (result.key == name) { + return result.item; + } + } } catch(ItemNotFoundException &e) { - errorstream<<"Waiting for clientcached timed out."<<std::endl; + errorstream<<"Waiting for clientcached " << name << " timed out."<<std::endl; return &m_dummy_clientcached; } } @@ -560,7 +563,7 @@ public: // Ensure that the "" item (the hand) always has ToolCapabilities if(def.name == "") assert(def.tool_capabilities != NULL); - + if(m_item_definitions.count(def.name) == 0) m_item_definitions[def.name] = new ItemDefinition(def); else |