From ea1255aff7b1ebcbefd3defa7e844aed5e38b3b1 Mon Sep 17 00:00:00 2001
From: Steve Huntley <stephen.huntley@alum.mit.edu>
Date: Mon, 28 Nov 2011 19:48:12 +0000
Subject: [PATCH] 2011-11-28  Steve Huntley  <stephen.huntley@alum.mit.edu>

	* vfslib.tcl: Applied contributed patch for bug 3412801.  Clean up watch
	timers for memchan vfs.
---
 ChangeLog          | 5 +++++
 library/vfslib.tcl | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 4522f18..243e906 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-28  Steve Huntley  <stephen.huntley@alum.mit.edu>
+
+	* vfslib.tcl: Applied contributed patch for bug 3412801.  Clean up watch
+	timers for memchan vfs.
+
 2011-11-28  Steve Huntley  <stephen.huntley@alum.mit.edu>
 
 	* zipvfs.tcl: Applied contributed patch for bug 3395782.  Enables 
diff --git a/library/vfslib.tcl b/library/vfslib.tcl
index 4d8e030..2862148 100644
--- a/library/vfslib.tcl
+++ b/library/vfslib.tcl
@@ -62,6 +62,12 @@ if {[info command ::chan] ne {}} {
             }
             finalize {
                 unset buf pos name
+                foreach event {read write} {
+                    upvar #0 ::vfs::_memchan(watch,$event) watch
+                    if {[info exists watch] && ([set idx [lsearch -exact $watch $chan]] >= 0)} {
+                        set watch [lreplace $watch $idx $idx]
+                    }
+                }
             }
             seek {
                 foreach {offset base} $args break
-- 
2.23.0