[Zodb-checkins] CVS: Packages/ZEO - smac.py:1.9.6.2
jeremy@digicool.com
jeremy@digicool.com
Thu, 29 Mar 2001 08:30:34 -0500 (EST)
Update of /cvs-repository/Packages/ZEO
In directory korak:/tmp/cvs-serv9470
Modified Files:
Tag: ZEO-ZRPC-Dev
smac.py
Log Message:
changes to aid debugging:
commented out "read_inprogress" checks
handler for unpack exceptions
--- Updated File smac.py in package Packages/ZEO --
--- smac.py 2001/03/17 00:25:36 1.9.6.1
+++ smac.py 2001/03/29 13:30:33 1.9.6.2
@@ -119,6 +119,8 @@
def __nonzero__(self):
return 1
+## __read_inprogress = None
+
def handle_read(self):
# Use a single __inp buffer and integer indexes to make this
# fast.
@@ -126,8 +128,10 @@
if not d:
return
+## self.__read_inprogress = 1
input_len = self.__input_len + len(d)
msg_size = self.__msg_size
+ state = self.__state
inp = self.__inp
if msg_size > input_len:
@@ -151,17 +155,28 @@
offset = 0
while (offset + msg_size) <= input_len:
- msg = inp[offset:offset+msg_size]
+## if state is None and msg_size != 4:
+## print "OUT OF LUCK"
+ msg = inp[offset:offset + msg_size]
offset = offset + msg_size
- if self.__state is None:
+ if state is None:
# waiting for message
- msg_size = struct.unpack(">i", msg)[0]
- self.__state = 1
+ try:
+ msg_size = struct.unpack(">i", msg)[0]
+ except:
+ # XXX
+ print 'unpack(">i", %s)' % repr(msg)
+ print "state = %s" % state
+ print "msg_size = %(msg_size)d, "\
+ "input_len= %(input_len)d" % locals()
+ raise
+ state = 1
else:
msg_size = 4
- self.__state = None
+ state = None
self.message_input(msg)
-
+
+ self.__state = state
self.__msg_size = msg_size
self.__inp = inp[offset:]
self.__input_len = input_len - offset
@@ -209,8 +224,10 @@
return 1
def writable(self):
- # inscrutable
- return not not self.__output
+ if len(self.__output) == 0:
+ return 0
+ else:
+ return 1
def handle_write(self):
output = self.__output
@@ -222,6 +239,7 @@
break # we can't write any more
else:
del output[0]
+# LOG(self._debug, INFO, "output written; remain=%d" % len(self.__output))
def handle_close(self):
self.close()
@@ -242,6 +260,7 @@
# do two separate appends to avoid copying the message string
self.__output.append(struct.pack(">i", len(message)))
self.__output.append(message)
+# LOG(self._debug, INFO, "output remain=%d" % len(self.__output))
def log_info(self, message, type='info'):
if type == 'error':