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,6 +89,8 @@ class SizedMessageAsyncConnection(asyncore.dispatcher): ...@@ -89,6 +89,8 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
return 1 return 1
def handle_read(self): def handle_read(self):
self.__input_lock.acquire()
try:
# Use a single __inp buffer and integer indexes to make this fast. # Use a single __inp buffer and integer indexes to make this fast.
try: try:
d = self.recv(8096) d = self.recv(8096)
...@@ -99,8 +101,6 @@ class SizedMessageAsyncConnection(asyncore.dispatcher): ...@@ -99,8 +101,6 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
if not d: if not d:
return 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