Commit e4869def authored by Guido van Rossum's avatar Guido van Rossum

Of course, the input lock must be held when doing the (non-blocking)

recv() call too, else there'd still be a race condition (two threads
both receiving some data, and then the last to read processing it
first, which would be a disaster).
parent c149480e
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Sized message async connections """Sized message async connections
$Id: smac.py,v 1.31 2002/09/29 03:22:28 gvanrossum Exp $ $Id: smac.py,v 1.32 2002/09/29 07:51:37 gvanrossum Exp $
""" """
import asyncore, struct import asyncore, struct
...@@ -89,18 +89,18 @@ class SizedMessageAsyncConnection(asyncore.dispatcher): ...@@ -89,18 +89,18 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
return 1 return 1
def handle_read(self): def handle_read(self):
# Use a single __inp buffer and integer indexes to make this fast. self.__input_lock.acquire()
try: try:
d = self.recv(8096) # Use a single __inp buffer and integer indexes to make this fast.
except socket.error, err: try:
if err[0] in expected_socket_read_errors: d = self.recv(8096)
except socket.error, err:
if err[0] in expected_socket_read_errors:
return
raise
if not d:
return return
raise
if not d:
return
self.__input_lock.acquire()
try:
input_len = self.__input_len + len(d) input_len = self.__input_len + len(d)
msg_size = self.__msg_size msg_size = self.__msg_size
state = self.__state state = self.__state
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment