From 29073a519a63dc248ea32b4434eddaaf15d72c2e Mon Sep 17 00:00:00 2001 From: HD Moore Date: Fri, 12 Nov 2010 17:28:40 +0000 Subject: [PATCH] Small tweaks to the thread code, add an update method git-svn-id: file:///home/svn/framework3/trunk@11011 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/core/thread_manager.rb | 24 ++++++++++++++++++++++++ lib/rex/io/stream_abstraction.rb | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/msf/core/thread_manager.rb b/lib/msf/core/thread_manager.rb index bee5793836..950b8d4f31 100644 --- a/lib/msf/core/thread_manager.rb +++ b/lib/msf/core/thread_manager.rb @@ -91,6 +91,30 @@ class ThreadManager < Array t end + # + # Updates an existing thread + # + def update(ut, name, crit) + ti = nil + self.each_index do |i| + tt = self[i] + next if not tt + if ut.__id__ == tt.__id__ + ti = i + break + end + end + + t = self[ti] + if not t + raise RuntimeError, "Thread not found" + end + + t[:tm_name] = name + t[:tm_crit] = crit + t + end + # # Kills a thread by index # diff --git a/lib/rex/io/stream_abstraction.rb b/lib/rex/io/stream_abstraction.rb index 93ab02e623..aee13f253b 100644 --- a/lib/rex/io/stream_abstraction.rb +++ b/lib/rex/io/stream_abstraction.rb @@ -122,7 +122,7 @@ module StreamAbstraction protected def monitor_rsock - self.monitor_thread = Rex::ThreadFactory.spawn("StreamMonitorRemote-#{self.peerinfo}", false) { + self.monitor_thread = Rex::ThreadFactory.spawn("StreamMonitorRemote", false) { loop do closed = false buf = nil