From: david-sarah <david-sarah@jacaranda.org>
Date: Sat, 6 Aug 2011 22:19:34 +0000 (-0700)
Subject: node.py: ensure that client and introducer nodes record their port number and use... 
X-Git-Url: https://git.rkrishnan.org/specifications/components/com_hotproperty/frontends?a=commitdiff_plain;h=05684b92517800460c9bba8a14f07f5e8139e847;p=tahoe-lafs%2Ftahoe-lafs.git

node.py: ensure that client and introducer nodes record their port number and use that port on the next restart, fixing a regression caused by #1385. fixes #1469.
---

diff --git a/src/allmydata/node.py b/src/allmydata/node.py
index 793729b5..eefce3d6 100644
--- a/src/allmydata/node.py
+++ b/src/allmydata/node.py
@@ -121,6 +121,18 @@ class Node(service.MultiService):
         self.config = ConfigParser.SafeConfigParser()
         self.config.read([os.path.join(self.basedir, "tahoe.cfg")])
 
+        cfg_tubport = self.get_config("node", "tub.port", "")
+        if not cfg_tubport:
+            # For 'tub.port', tahoe.cfg overrides the individual file on
+            # disk. So only read self._portnumfile if tahoe.cfg doesn't
+            # provide a value.
+            try:
+                file_tubport = fileutil.read(self._portnumfile).strip()
+                self.set_config("node", "tub.port", file_tubport)
+            except EnvironmentError:
+                if os.path.exists(self._portnumfile):
+                    raise
+
     def error_about_old_config_files(self):
         """ If any old configuration files are detected, raise OldConfigError. """