From 197595839a23f1e4cce61271cd97c840bb79da6c Mon Sep 17 00:00:00 2001 From: HD Moore Date: Mon, 12 Apr 2010 19:25:29 +0000 Subject: [PATCH] Add a close method, fix a memory leak git-svn-id: file:///home/svn/framework3/trunk@9056 4d416f70-5f16-0410-b530-b9f4589650da --- lib/msf/core/rpc/client.rb | 4 ++++ lib/msf/core/rpc/service.rb | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lib/msf/core/rpc/client.rb b/lib/msf/core/rpc/client.rb index 3844e70ce4..879b3d1680 100644 --- a/lib/msf/core/rpc/client.rb +++ b/lib/msf/core/rpc/client.rb @@ -61,6 +61,10 @@ class Client < ::XMLRPC::Client super(meth, *args) end + def close + self.sock.close + end + end end end diff --git a/lib/msf/core/rpc/service.rb b/lib/msf/core/rpc/service.rb index f43e84f054..89dc3d5abe 100644 --- a/lib/msf/core/rpc/service.rb +++ b/lib/msf/core/rpc/service.rb @@ -50,6 +50,7 @@ class Service < ::XMLRPC::BasicServer def on_client_connect(c) self.state[c] = "" + self.clean_state_table end def on_client_data(c) @@ -62,6 +63,12 @@ class Service < ::XMLRPC::BasicServer procxml(c) end + def clean_state_table + self.state.keys.each do |s| + self.state.delete(s) if s.closed? + end + end + def procxml(c) while(self.state[c].index("\x00")) mesg,left = self.state[c].split("\x00", 2)