[Zodb-checkins] CVS: Zope/lib/python/ZEO - simul.py:1.13.2.2 start.py:1.47.2.2

Chris McDonough chrism@zope.com
Sat, 26 Oct 2002 15:52:19 -0400


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

Modified Files:
      Tag: chrism-install-branch
	simul.py start.py 
Log Message:
Merge with HEAD.  Again, sorry for the spew (what's left of it... someone seems to have filtered some of this branch's checkins out).


=== Zope/lib/python/ZEO/simul.py 1.13.2.1 => 1.13.2.2 ===
--- Zope/lib/python/ZEO/simul.py:1.13.2.1	Tue Oct  8 20:41:42 2002
+++ Zope/lib/python/ZEO/simul.py	Sat Oct 26 15:51:48 2002
@@ -97,13 +97,28 @@
     sim.printheader()
 
     # Read trace file, simulating cache behavior
+    offset = 0
+    records = 0
+    f_read = f.read
+    struct_unpack = struct.unpack
     while 1:
-        # Read a record
-        r = f.read(24)
-        if len(r) < 24:
+        # Read a record and decode it
+        r = f_read(8)
+        if len(r) < 8:
             break
-        # Decode it
-        ts, code, oid, serial = struct.unpack(">ii8s8s", r)
+        offset += 8
+        ts, code = struct_unpack(">ii", r)
+        if ts == 0:
+            # Must be a misaligned record caused by a crash
+            ##print "Skipping 8 bytes at offset", offset-8
+            continue
+        r = f_read(16)
+        if len(r) < 16:
+            break
+        offset += 16
+        records += 1
+        oid, serial = struct_unpack(">8s8s", r)
+        # Decode the code
         dlen, version, code, current = (code & 0x7fffff00,
                                         code & 0x80,
                                         code & 0x7e,


=== Zope/lib/python/ZEO/start.py 1.47.2.1 => 1.47.2.2 ===
--- Zope/lib/python/ZEO/start.py:1.47.2.1	Tue Oct  8 20:41:42 2002
+++ Zope/lib/python/ZEO/start.py	Sat Oct 26 15:51:48 2002
@@ -81,25 +81,21 @@
     except ImportError:
         return
 
-    try:
-        xfsz = signal.SIFXFSZ
-    except AttributeError:
-        pass
-    else:
-        signal.signal(xfsz, signal.SIG_IGN)
-    signal.signal(signal.SIGTERM, lambda sig, frame: shutdown(storages))
-    signal.signal(signal.SIGINT, lambda sig, frame: shutdown(storages, 0))
-    try:
-        signal.signal(signal.SIGHUP, rotate_logs_handler)
-    except:
-        pass
+    if hasattr(signal, 'SIGXFSZ'):
+        signal.signal(signal.SIGXFSZ, signal.SIG_IGN)
+    if hasattr(signal, 'SIGTERM'):
+        signal.signal(signal.SIGTERM, lambda sig, frame: shutdown(storages))
+    if hasattr(signal, 'SIGHUP'):
+        signal.signal(signal.SIGHUP, lambda sig, frame: shutdown(storages, 0))
+    if hasattr(signal, 'SIGUSR2'):
+        signal.signal(signal.SIGUSR2, rotate_logs_handler)
 
 def main(argv):
     me = argv[0]
     sys.path.insert(0, directory(me, 2))
 
     global LOG, INFO, ERROR
-    from zLOG import LOG, INFO, ERROR, PANIC
+    from zLOG import LOG, INFO, WARNING, ERROR, PANIC
     from ZEO.util import Environment
     env = Environment(me)
 
@@ -223,10 +219,19 @@
             pass
         else:
             import zdaemon
-            zdaemon.run(sys.argv, '')
+            zdaemon.run(sys.argv, env.zeo_pid)
 
     try:
 
+        if Z:
+            # Change current directory (for core dumps etc.)
+            try:
+                os.chdir(env.var)
+            except os.error:
+                LOG('ZEO/start.py', WARNING, "Couldn't chdir to %s" % env.var)
+            else:
+                LOG('ZEO/start.py', INFO, "Changed directory to %s" % env.var)
+
         import ZEO.StorageServer, asyncore
 
         storages = {}
@@ -258,14 +263,15 @@
 
         ZEO.StorageServer.StorageServer(unix, storages)
 
-        try:
-            ppid, pid = os.getppid(), os.getpid()
-        except:
-            pass # getpid not supported
-        else:
-            f = open(env.zeo_pid, 'w')
-            f.write("%s %s\n" % (ppid, pid))
-            f.close()
+        if not Z:
+            try:
+                pid = os.getpid()
+            except:
+                pass # getpid not supported
+            else:
+                f = open(env.zeo_pid, 'w')
+                f.write("%s\n" % pid)
+                f.close()
 
     except:
         # Log startup exception and tell zdaemon not to restart us.
@@ -314,9 +320,6 @@
 
 def rotate_logs_handler(signum, frame):
     rotate_logs()
-
-    import signal
-    signal.signal(signal.SIGHUP, rotate_logs_handler)
 
 def shutdown(storages, die=1):
     LOG("ZEO/start.py", INFO, "Received signal")