[Zodb-checkins] CVS: Zope/lib/python/ZEO - ClientStorage.py:1.76.2.3 StorageServer.py:1.76.2.3 runsvr.py:1.14.2.2 start.py:1.47.2.4

Chris McDonough chrism@zope.com
Fri, 3 Jan 2003 01:37:04 -0500


Update of /cvs-repository/Zope/lib/python/ZEO
In directory cvs.zope.org:/tmp/cvs-serv28385

Modified Files:
      Tag: chrism-install-branch
	ClientStorage.py StorageServer.py runsvr.py start.py 
Log Message:
Merging chrism-install-branch with HEAD (hopefully for one of the last
times).



=== Zope/lib/python/ZEO/ClientStorage.py 1.76.2.2 => 1.76.2.3 ===
--- Zope/lib/python/ZEO/ClientStorage.py:1.76.2.2	Sun Nov 24 18:55:25 2002
+++ Zope/lib/python/ZEO/ClientStorage.py	Fri Jan  3 01:36:31 2003
@@ -266,9 +266,7 @@
 
     def close(self):
         """Storage API: finalize the storage, releasing external resources."""
-        if self._tbuf is not None:
-            self._tbuf.close()
-            self._tbuf = None
+        self._tbuf.close()
         if self._cache is not None:
             self._cache.close()
             self._cache = None
@@ -611,7 +609,7 @@
         self._server.vote(self._serial)
         return self._check_serials()
 
-    def tpc_begin(self, transaction, tid=None, status=' '):
+    def tpc_begin(self, txn, tid=None, status=' '):
         """Storage API: begin a transaction."""
         if self._is_read_only:
             raise POSException.ReadOnlyError()
@@ -620,11 +618,11 @@
             # It is allowable for a client to call two tpc_begins in a
             # row with the same transaction, and the second of these
             # must be ignored.
-            if self._transaction == transaction:
+            if self._transaction == txn:
                 self._tpc_cond.release()
                 return
             self._tpc_cond.wait(30)
-        self._transaction = transaction
+        self._transaction = txn
         self._tpc_cond.release()
 
         if tid is None:
@@ -635,11 +633,8 @@
             id = tid
 
         try:
-            r = self._server.tpc_begin(id,
-                                       transaction.user,
-                                       transaction.description,
-                                       transaction._extension,
-                                       tid, status)
+            self._server.tpc_begin(id, txn.user, txn.description,
+                                   txn._extension, tid, status)
         except:
             # Client may have disconnected during the tpc_begin().
             if self._server is not disconnected_stub:


=== Zope/lib/python/ZEO/StorageServer.py 1.76.2.2 => 1.76.2.3 ===
--- Zope/lib/python/ZEO/StorageServer.py:1.76.2.2	Sun Nov 24 18:55:25 2002
+++ Zope/lib/python/ZEO/StorageServer.py	Fri Jan  3 01:36:31 2003
@@ -347,13 +347,33 @@
 
     def zeoVerify(self, oid, s, sv):
         try:
-            p, os, v, pv, osv = self.zeoLoad(oid)
-        except: # except what?
-            return None
-        if os != s:
+            os = self.storage.getSerial(oid)
+        except KeyError:
             self.client.invalidateVerify((oid, ''))
-        elif osv != sv:
-            self.client.invalidateVerify((oid, v))
+            # XXX It's not clear what we should do now.  The KeyError
+            # could be caused by an object uncreation, in which case
+            # invalidation is right.  It could be an application bug
+            # that left a dangling reference, in which case it's bad.
+        else:
+            # If the client has version data, the logic is a bit more
+            # complicated.  If the current serial number matches the
+            # client serial number, then the non-version data must
+            # also be valid.  If the current serialno is for a
+            # version, then the non-version data can't change.
+
+            # If the version serialno isn't valid, then the
+            # non-version serialno may or may not be valid.  Rather
+            # than trying to figure it whether it is valid, we just
+            # invalidate it.  Sending an invalidation for the
+            # non-version data implies invalidating the version data
+            # too, since an update to non-version data can only occur
+            # after the version is aborted or committed.
+            if sv:
+                if sv != os:
+                    self.client.invalidateVerify((oid, ''))
+            else:
+                if s != os:
+                    self.client.invalidateVerify((oid, ''))
 
     def endZeoVerify(self):
         self.client.endVerify()


=== Zope/lib/python/ZEO/runsvr.py 1.14.2.1 => 1.14.2.2 ===
--- Zope/lib/python/ZEO/runsvr.py:1.14.2.1	Sun Nov 24 18:55:25 2002
+++ Zope/lib/python/ZEO/runsvr.py	Fri Jan  3 01:36:31 2003
@@ -39,11 +39,7 @@
 import socket
 
 import zLOG
-
-import ZConfig
-import ZConfig.Common
-
-import ZODB.StorageConfig
+import ZConfig.Context
 
 
 class Options:
@@ -125,7 +121,11 @@
     def load_configuration(self):
         if self.rootconf or not self.configuration:
             return
-        self.rootconf = ZConfig.load(self.configuration)
+        c = ZConfig.Context.Context()
+        try:
+            self.rootconf = c.loadURL(self.configuration)
+        except ZConfig.ConfigurationError, errobj:
+            self.usage(str(errobj))
 
     def help(self):
         """Print a long help message (self.doc) to stdout and exit(0).
@@ -207,7 +207,7 @@
             return
         try:
             self.hostconf = self.rootconf.getSection("Host")
-        except ZConfig.Common.ConfigurationConflictingSectionError:
+        except ZConfig.ConfigurationConflictingSectionError:
             if not self.hostname:
                 self.hostname = socket.getfqdn()
             self.hostconf = self.rootconf.getSection("Host", self.hostname)
@@ -273,6 +273,7 @@
             return
         storagesections = self.zeoconf.getChildSections("Storage")
         self.storages = {}
+        import ZODB.StorageConfig
         for section in storagesections:
             name = section.name
             if not name:
@@ -358,8 +359,8 @@
         self.server = StorageServer(self.options.address, self.storages)
 
     def loop_forever(self):
-        import asyncore
-        asyncore.loop()
+        import ThreadedAsync.LoopCallback
+        ThreadedAsync.LoopCallback.loop()
 
     def handle_sigterm(self):
         info("terminated by SIGTERM")
@@ -376,6 +377,7 @@
         # XXX Shouldn't this be below with _log()?
         import zLOG
         zLOG.initialize()
+        info("reinitialized zLOG")
 
     def close_storages(self):
         for name, storage in self.storages.items():


=== Zope/lib/python/ZEO/start.py 1.47.2.3 => 1.47.2.4 ===
--- Zope/lib/python/ZEO/start.py:1.47.2.3	Sun Nov 24 18:55:26 2002
+++ Zope/lib/python/ZEO/start.py	Fri Jan  3 01:36:31 2003
@@ -19,6 +19,7 @@
 import types
 import errno
 import socket
+import ThreadedAsync.LoopCallback
 
 def directory(p, n=1):
     d = p
@@ -95,8 +96,6 @@
 def main(argv):
     me = argv[0]
     sys.path.insert(0, directory(me, 2))
-    import zLOG
-    zLOG.initialize()
 
     global LOG, INFO, ERROR
     from zLOG import LOG, INFO, WARNING, ERROR, PANIC
@@ -135,7 +134,7 @@
 
        -p port -- port to listen on
 
-       -h adddress -- host address to listen on
+       -h address -- host address to listen on
 
        -s -- Don't use zdeamon
 
@@ -213,7 +212,7 @@
         os.environ['Z_DEBUG_MODE'] = '1'
     if detailed:
         os.environ['STUPID_LOG_SEVERITY'] = '-300'
-        zLOG.initialize()
+        rotate_logs() # reinitialize zLOG
 
     set_uid(UID)
 
@@ -293,7 +292,7 @@
 
     try:
         try:
-            asyncore.loop()
+            ThreadedAsync.LoopCallback.loop()
         finally:
             if os.path.isfile(env.zeo_pid):
                 os.unlink(env.zeo_pid)
@@ -314,15 +313,18 @@
     init = getattr(zLOG, 'initialize', None)
     if init is not None:
         init()
-        return
-    # This will work if the minimal logger is in use, but not if some
-    # other logger is active.  MinimalLogger exists only in Zopes
-    # pre-2.7.
-    try:
-        import zLOG.MinimalLogger
-        zLOG.MinimalLogger._log.initialize()
-    except ImportError:
-        pass
+    else:
+        # This will work if the minimal logger is in use, but not if some
+        # other logger is active.  MinimalLogger exists only in Zopes
+        # pre-2.7.
+        try:
+            import zLOG.MinimalLogger
+            zLOG.MinimalLogger._log.initialize()
+        except ImportError:
+            zLOG.LOG("ZEO/start.py", zLOG.WARNING,
+                     "Caught USR2, could not rotate logs")
+            return
+    zLOG.LOG("ZEO/start.py", zLOG.INFO, "Caught USR2, logs rotated")
 
 def rotate_logs_handler(signum, frame):
     rotate_logs()