Clear stale fds out of cache in ajaxterm
authorEric Price <ecprice@mit.edu>
Fri, 21 Aug 2009 16:13:43 +0000 (12:13 -0400)
committerEric Price <ecprice@mit.edu>
Fri, 21 Aug 2009 16:13:43 +0000 (12:13 -0400)
svn path=/package_branches/invirt-web/ajaxterm-rebased/; revision=2757

code/main.py

index f42e1fd..ecb4363 100755 (executable)
@@ -419,9 +419,14 @@ console will suffer artifacts.
                     term = self.atsessions[machine_id]
                 else:
                     print >>sys.stderr, "spawning new session for terminal to ",machine_id
                     term = self.atsessions[machine_id]
                 else:
                     print >>sys.stderr, "spawning new session for terminal to ",machine_id
-                    term = self.atsessions[machine_id] = self.atmulti.create(
+                    term = self.atmulti.create(
                         ["ssh", "-e","none", "-l", machine.name, config.console.hostname]
                         )
                         ["ssh", "-e","none", "-l", machine.name, config.console.hostname]
                         )
+                    # Clear out old sessions when fd is reused
+                    for key in self.atsessions:
+                        if self.atsessions[key] == term:
+                            del self.atsessions[key]
+                    self.atsessions[machine_id] = term
                 if k:
                     self.atmulti.proc_write(term,k)
                 time.sleep(0.002)
                 if k:
                     self.atmulti.proc_write(term,k)
                 time.sleep(0.002)