Commit 4a34bfaf authored by Jeremy Hylton's avatar Jeremy Hylton

Fix error handling logic for pickling errors.

If an exception occurs while decoding a message, there is really
nothing the server can do to recover.  If the message was a
synchronous call, the client will wait for ever for the reply.  The
server can't send the reply, because it couldn't unpickle the message
id.  Instead of trying to recover, just let the exception propogate up
to asyncore where the connection will be closed.

As a result, eliminate DecodingError and special case in
handle_error() that handled flags == None.
parent 6d40690c
......@@ -20,7 +20,7 @@ import types
import ThreadedAsync
from ZEO.zrpc import smac
from ZEO.zrpc.error import ZRPCError, DisconnectedError, DecodingError
from ZEO.zrpc.error import ZRPCError, DisconnectedError
from ZEO.zrpc.log import log, short_repr
from ZEO.zrpc.marshal import Marshaller
from ZEO.zrpc.trigger import trigger
......@@ -188,13 +188,11 @@ class Connection(smac.SizedMessageAsyncConnection):
def message_input(self, message):
"""Decoding an incoming message and dispatch it"""
# XXX Not sure what to do with errors that reach this level.
# Need to catch ZRPCErrors in handle_reply() and
# handle_request() so that they get back to the client.
try:
msgid, flags, name, args = self.marshal.decode(message)
except DecodingError, msg:
return self.return_error(None, None, DecodingError, msg)
# If something goes wrong during decoding, the marshaller
# will raise an exception. The exception will ultimately
# result in asycnore calling handle_error(), which will
# close the connection.
msgid, flags, name, args = self.marshal.decode(message)
if __debug__:
log("recv msg: %s, %s, %s, %s" % (msgid, flags, name,
......@@ -276,9 +274,6 @@ class Connection(smac.SizedMessageAsyncConnection):
self.poll()
def return_error(self, msgid, flags, err_type, err_value):
if flags is None:
self.log_error("Exception raised during decoding")
return
if flags & ASYNC:
self.log_error("Asynchronous call raised exception: %s" % self)
return
......
......@@ -17,8 +17,5 @@ from ZEO.Exceptions import Disconnected
class ZRPCError(POSException.StorageError):
pass
class DecodingError(ZRPCError):
"""A ZRPC message could not be decoded."""
class DisconnectedError(ZRPCError, Disconnected):
"""The database storage is disconnected from the storage server."""
......@@ -18,7 +18,7 @@ import types
import zLOG
from ZEO.zrpc.error import ZRPCError, DecodingError
from ZEO.zrpc.error import ZRPCError
from ZEO.zrpc.log import log
class Marshaller:
......@@ -50,8 +50,8 @@ class Marshaller:
try:
return unpickler.load() # msgid, flags, name, args
except (self.errors, IndexError), err_msg:
log("can't decode %s" % repr(msg), level=zLOG.ERROR)
raise DecodingError(msg)
log("can't decode message: %s" % repr(msg), level=zLOG.ERROR)
raise
_globals = globals()
_silly = ('__doc__',)
......
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