Fix locking bugs and make inventory deserialization errors more specific
authorShadowNinja <shadowninja@minetest.net>
Fri, 12 Sep 2014 00:12:52 +0000 (20:12 -0400)
committerShadowNinja <shadowninja@minetest.net>
Sun, 21 Sep 2014 18:39:36 +0000 (14:39 -0400)
src/inventory.cpp
src/server.cpp

index 4b1beb230c6a90fbe9dd71b463a433fb6d5638be..4766524dddb37a1b8c98328fb4dc3473db5de88e 100644 (file)
@@ -938,7 +938,7 @@ void Inventory::deSerialize(std::istream &is)
                }
                else
                {
-                       throw SerializationError("invalid inventory specifier");
+                       throw SerializationError("invalid inventory specifier: " + name);
                }
        }
 }
index fd9e1ce7b5a82ae7ceb779d5e08243ec794f09b8..262970c09a195bdd96615121d2b0e8e40683097d 100644 (file)
@@ -1169,10 +1169,15 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
        std::string playername = "";
        PlayerSAO *playersao = NULL;
        m_clients.Lock();
-       RemoteClient* client = m_clients.lockedGetClientNoEx(peer_id, CS_InitDone);
-       if (client != NULL) {
-               playername = client->getName();
-               playersao = emergePlayer(playername.c_str(), peer_id);
+       try {
+               RemoteClient* client = m_clients.lockedGetClientNoEx(peer_id, CS_InitDone);
+               if (client != NULL) {
+                       playername = client->getName();
+                       playersao = emergePlayer(playername.c_str(), peer_id);
+               }
+       } catch (std::exception &e) {
+               m_clients.Unlock();
+               throw;
        }
        m_clients.Unlock();
 
@@ -3869,7 +3874,7 @@ void Server::SendBlocks(float dtime)
                        RemoteClient *client = m_clients.lockedGetClientNoEx(*i, CS_Active);
 
                        if (client == NULL)
-                               return;
+                               continue;
 
                        total_sending += client->SendingCount();
                        client->GetNextBlocks(m_env,m_emerge, dtime, queue);