Commit b3afdce3 authored by Jim Fulton's avatar Jim Fulton

- Clear transaction data when disconnected.

- Return error is we get a begin request from a connection that
  already has an active transaction.

- Log connections and disconnection logging. Someone (Sam) decided to
  comment this out of the asyncore code.

- Include connection id in debugging messages.
parent 952c0d8f
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__version__ = "$Revision: 1.12 $"[11:-2] __version__ = "$Revision: 1.13 $"[11:-2]
import asyncore, socket, string, sys, cPickle, os import asyncore, socket, string, sys, cPickle, os
from smac import SizedMessageAsyncConnection from smac import SizedMessageAsyncConnection
...@@ -99,7 +99,7 @@ from cStringIO import StringIO ...@@ -99,7 +99,7 @@ from cStringIO import StringIO
class StorageServerError(POSException.StorageError): pass class StorageServerError(POSException.StorageError): pass
def blather(*args): def blather(*args):
LOG('ZEO Server', TRACE, string.join(args)) LOG('ZEO Server', TRACE, string.join(map(str,args)))
# We create a special fast pickler! This allows us # We create a special fast pickler! This allows us
...@@ -227,16 +227,21 @@ class Connection(SizedMessageAsyncConnection): ...@@ -227,16 +227,21 @@ class Connection(SizedMessageAsyncConnection):
if __debug__: debug='ZEO Server' if __debug__: debug='ZEO Server'
else: debug=0 else: debug=0
SizedMessageAsyncConnection.__init__(self, sock, addr, debug=debug) SizedMessageAsyncConnection.__init__(self, sock, addr, debug=debug)
LOG('ZEO Server', INFO, 'Connect %s %s' % (id(self), `addr`))
def close(self): def close(self):
t=self._transaction t=self._transaction
if (t is not None and self.__storage is not None and if (t is not None and self.__storage is not None and
self.__storage._transaction is t): self.__storage._transaction is t):
self.tpc_abort(t.id) self.tpc_abort(t.id)
else:
self._transaction=None
self.__invalidated=[]
self.__server.unregister_connection(self, self.__storage_id) self.__server.unregister_connection(self, self.__storage_id)
self.__closed=1 self.__closed=1
SizedMessageAsyncConnection.close(self) SizedMessageAsyncConnection.close(self)
LOG('ZEO Server', INFO, 'Close %s' % id(self))
def message_input(self, message, def message_input(self, message,
dump=dump, Unpickler=Unpickler, StringIO=StringIO, dump=dump, Unpickler=Unpickler, StringIO=StringIO,
...@@ -244,7 +249,7 @@ class Connection(SizedMessageAsyncConnection): ...@@ -244,7 +249,7 @@ class Connection(SizedMessageAsyncConnection):
if __debug__: if __debug__:
m=`message` m=`message`
if len(m) > 60: m=m[:60]+' ...' if len(m) > 60: m=m[:60]+' ...'
blather('message_input', m) blather('message_input', m, id(self))
if self.__storage is None: if self.__storage is None:
self.__storage, self.__storage_id = ( self.__storage, self.__storage_id = (
...@@ -263,7 +268,7 @@ class Connection(SizedMessageAsyncConnection): ...@@ -263,7 +268,7 @@ class Connection(SizedMessageAsyncConnection):
if __debug__: if __debug__:
m=`tuple(args)` m=`tuple(args)`
if len(m) > 90: m=m[:90]+' ...' if len(m) > 90: m=m[:90]+' ...'
blather('call: %s%s' % (name, m)) blather('call: %s%s' % (name, m), id(self))
if not storage_method(name): if not storage_method(name):
raise 'Invalid Method Name', name raise 'Invalid Method Name', name
...@@ -281,7 +286,7 @@ class Connection(SizedMessageAsyncConnection): ...@@ -281,7 +286,7 @@ class Connection(SizedMessageAsyncConnection):
if __debug__: if __debug__:
m=`r` m=`r`
if len(m) > 60: m=m[:60]+' ...' if len(m) > 60: m=m[:60]+' ...'
blather('%s: %s' % (rt, m)) blather('%s: %s' % (rt, m), id(self))
try: r=dump(r,1) try: r=dump(r,1)
except: except:
...@@ -431,7 +436,13 @@ class Connection(SizedMessageAsyncConnection): ...@@ -431,7 +436,13 @@ class Connection(SizedMessageAsyncConnection):
def tpc_begin(self, id, user, description, ext): def tpc_begin(self, id, user, description, ext):
t=self._transaction t=self._transaction
if t is not None and id == t.id: return if t is not None:
if id == t.id: return
else:
raise StorageServerError(
"Multiple simultaneous tpc_begin requests from the same "
"client."
)
storage=self.__storage storage=self.__storage
if storage._transaction is not None: if storage._transaction is not None:
try: waiting=storage.__waiting try: waiting=storage.__waiting
......
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