fixed: jsonrpc would deadlock with app thread when doing a playlist operation while...
authorbobo1on1 <bobo1on1@svn>
Wed, 22 Sep 2010 20:05:57 +0000 (20:05 +0000)
committerbobo1on1 <bobo1on1@svn>
Wed, 22 Sep 2010 20:05:57 +0000 (20:05 +0000)
to reproduce: play some music then send {"jsonrpc": "2.0", "method": "AudioPlaylist.Play", "params" : { "songid": 1 },  "id": 1} to jsonrpc server

(cherry picked from commit f0ae32c36483c81c0b6e93fbdd1f43325a45d62c)

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@34076 568bbfeb-2a22-0410-94d2-cc84cf5bfa90

xbmc/lib/libjsonrpc/TCPServer.cpp

index 60c39fa..6f07ec8 100644 (file)
@@ -276,8 +276,8 @@ void CTCPServer::CTCPClient::PushBuffer(CTCPServer *host, const char *buffer, in
       m_endBrackets++;
     if (m_beginBrackets > 0 && m_endBrackets > 0 && m_beginBrackets == m_endBrackets)
     {
-      CSingleLock lock (m_critSection);
       std::string line = CJSONRPC::MethodCall(m_buffer, host, this);
+      CSingleLock lock (m_critSection);
       send(m_socket, line.c_str(), line.size(), 0);
       m_beginBrackets = m_endBrackets = 0;
       m_buffer.clear();