Merge pull request #827 from trygveaa/fix/network-thread-issue

network: disable_recv before telling actor to close connection
This commit is contained in:
Stein Magnus Jodal 2014-08-29 13:36:48 +02:00
commit 2830784703
3 changed files with 10 additions and 4 deletions

View File

@ -21,6 +21,9 @@ Bug fix release.
- Configuration: :option:`mopidy --config` now supports directories.
- Network: Fix a race condition where two threads could try to free the same
data simultaneously. (Fixes: :issue:`781`)
v0.19.3 (2014-08-03)
====================

View File

@ -268,8 +268,8 @@ class Connection(object):
return True
if not data:
self.actor_ref.tell({'close': True})
self.disable_recv()
self.actor_ref.tell({'close': True})
return True
try:

View File

@ -7,7 +7,7 @@ import unittest
import gobject
from mock import Mock, patch, sentinel
from mock import Mock, call, patch, sentinel
import pykka
@ -418,8 +418,11 @@ class ConnectionTest(unittest.TestCase):
self.assertTrue(network.Connection.recv_callback(
self.mock, sentinel.fd, gobject.IO_IN))
self.mock.actor_ref.tell.assert_called_once_with({'close': True})
self.mock.disable_recv.assert_called_once_with()
self.assertEqual(self.mock.mock_calls, [
call.sock.recv(any_int),
call.disable_recv(),
call.actor_ref.tell({'close': True}),
])
def test_recv_callback_recoverable_error(self):
self.mock.sock = Mock(spec=socket.SocketType)