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